Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,51 +22,53 @@ commands:
steps:
- run:
name: yarn test
command: yarn test
lint:
steps:
- run:
name: yarn lint
command: CI=true yarn lint

command: yarn test:ci
install_and_test:
steps:
- install_and_cache_yarn_linux
- run_all_tests
- lint

# based on https://github.com/nodejs/Release schedule
jobs:
node v10:
Node v10:
docker:
- image: circleci/node:10
steps:
- install_and_test
node v12:
Node v12:
docker:
- image: circleci/node:12
steps:
- install_and_test
node v14:
Node v14:
docker:
- image: circleci/node:14
steps:
- install_and_test
node v14_6:
Node v14_16:
docker:
- image: circleci/node:14.6.0
- image: circleci/node:14.16.0
steps:
- install_and_test
node v15:
Node v15:
docker:
- image: circleci/node:15
steps:
- install_and_test
Linting:
docker:
- image: circleci/node:14.16.0
steps:
- install_and_cache_yarn_linux
- run:
name: yarn lint
command: CI=true yarn lint
workflows:
main:
jobs:
- node v10
- node v12
- node v14
- node v14_6
- node v15
- Linting
- Node v10
- Node v12
- Node v14
- Node v14_16
- Node v15
1,220 changes: 1,220 additions & 0 deletions __mocks__/octocat.js

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions __tests__/download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
var request = require("supertest")
var app = require("./testing").app

/**
* NOTE: the download test suite has a dependency on github.com
* Work still needs to be done to refactor the code to prevent this with a mock
*/

var MAC_USERAGENT =
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us)" +
" AppleWebKit/530.19.2 (KHTML, like Gecko) Version/4.0.2 Safari/530.19"
var WIN_USERAGENT =
"Mozilla/5.0 (Windows NT 6.3; Trident/7.0; Touch; rv:11.0) like Gecko"

describe("Download", function () {
var agent = request.agent(app)

describe("Latest version (/)", function () {
test("should fail if no user-agent to detect platform", function (done) {
agent.get("/").expect(400, done)
})

test("should download windows file", function (done) {
agent
.get("/")
.set("User-Agent", WIN_USERAGENT)
.expect(200)
.expect("Content-Disposition", "attachment; filename=test.exe")
.expect("Content-Length", "22")
.end(done)
})

test("should download OS X file as DMG", function (done) {
agent
.get("/")
.set("User-Agent", MAC_USERAGENT)
.expect(200)
.expect("Content-Disposition", "attachment; filename=test-osx.dmg")
.expect("Content-Length", "22")
.end(done)
})
})

describe("Previous version (/download/version/)", function () {
test("should not have a windows file to download", function (done) {
agent
.get("/download/version/0.9.0")
.set("User-Agent", WIN_USERAGENT)
.expect(404)
.end(done)
})

test("should download OS X file as DMG", function (done) {
agent
.get("/download/version/0.9.0")
.set("User-Agent", MAC_USERAGENT)
.expect(200)
.expect("Content-Disposition", "attachment; filename=test-osx.dmg")
.expect("Content-Length", "22")
.end(done)
})
})
})
163 changes: 77 additions & 86 deletions test/platforms.js → __tests__/platforms.js
Original file line number Diff line number Diff line change
@@ -1,79 +1,70 @@
require("should")
var platforms = require("../lib/utils/platforms")
var useragent = require("express-useragent")

describe("Platforms", function () {
describe("Detect", function () {
it("should detect osx_64", function () {
platforms
.detect("myapp-v0.25.1-darwin-x64.zip")
.should.be.exactly(platforms.OSX_64)
platforms.detect("myapp.dmg").should.be.exactly(platforms.OSX_64)
test("should detect osx_64", function () {
expect(platforms.detect("myapp-v0.25.1-darwin-x64.zip")).toEqual(
platforms.OSX_64,
)
expect(platforms.detect("myapp.dmg")).toEqual(platforms.OSX_64)
})

it("should detect windows_32", function () {
platforms
.detect("myapp-v0.25.1-win32-ia32.zip")
.should.be.exactly(platforms.WINDOWS_32)
platforms
.detect("atom-1.0.9-delta.nupkg")
.should.be.exactly(platforms.WINDOWS_32)
platforms.detect("RELEASES").should.be.exactly(platforms.WINDOWS_32)
test("should detect windows_32", function () {
expect(platforms.detect("myapp-v0.25.1-win32-ia32.zip")).toEqual(
platforms.WINDOWS_32,
)
expect(platforms.detect("atom-1.0.9-delta.nupkg")).toEqual(
platforms.WINDOWS_32,
)
expect(platforms.detect("RELEASES")).toEqual(platforms.WINDOWS_32)
})

it("should detect windows_64", function () {
platforms.detect("MyApp-x64.exe").should.be.exactly(platforms.WINDOWS_64)
test("should detect windows_64", function () {
expect(platforms.detect("MyApp-x64.exe")).toEqual(platforms.WINDOWS_64)
var chrome = useragent.parse(
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36",
)
platforms
.detectPlatformByUserAgent(chrome)
.should.be.exactly(platforms.WINDOWS_64)
expect(platforms.detectPlatformByUserAgent(chrome)).toEqual(
platforms.WINDOWS_64,
)
var edge = useragent.parse(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586",
)
platforms
.detectPlatformByUserAgent(edge)
.should.be.exactly(platforms.WINDOWS_64)
expect(platforms.detectPlatformByUserAgent(edge)).toEqual(
platforms.WINDOWS_64,
)
})

it("should detect linux", function () {
platforms
.detect("enterprise-amd64.tar.gz")
.should.be.exactly(platforms.LINUX_64)
platforms
.detect("enterprise-amd64.tgz")
.should.be.exactly(platforms.LINUX_64)
platforms
.detect("enterprise-ia32.tar.gz")
.should.be.exactly(platforms.LINUX_32)
platforms
.detect("enterprise-ia32.tgz")
.should.be.exactly(platforms.LINUX_32)
test("should detect linux", function () {
expect(platforms.detect("enterprise-amd64.tar.gz")).toEqual(
platforms.LINUX_64,
)
expect(platforms.detect("enterprise-amd64.tgz")).toEqual(
platforms.LINUX_64,
)
expect(platforms.detect("enterprise-ia32.tar.gz")).toEqual(
platforms.LINUX_32,
)
expect(platforms.detect("enterprise-ia32.tgz")).toEqual(
platforms.LINUX_32,
)
})

it("should detect debian_32", function () {
platforms
.detect("atom-ia32.deb")
.should.be.exactly(platforms.LINUX_DEB_32)
test("should detect debian_32", function () {
expect(platforms.detect("atom-ia32.deb")).toEqual(platforms.LINUX_DEB_32)
})

it("should detect debian_64", function () {
platforms
.detect("atom-amd64.deb")
.should.be.exactly(platforms.LINUX_DEB_64)
test("should detect debian_64", function () {
expect(platforms.detect("atom-amd64.deb")).toEqual(platforms.LINUX_DEB_64)
})

it("should detect rpm_32", function () {
platforms
.detect("atom-ia32.rpm")
.should.be.exactly(platforms.LINUX_RPM_32)
test("should detect rpm_32", function () {
expect(platforms.detect("atom-ia32.rpm")).toEqual(platforms.LINUX_RPM_32)
})

it("should detect rpm_64", function () {
platforms
.detect("atom-amd64.rpm")
.should.be.exactly(platforms.LINUX_RPM_64)
test("should detect rpm_64", function () {
expect(platforms.detect("atom-amd64.rpm")).toEqual(platforms.LINUX_RPM_64)
})
})

Expand Down Expand Up @@ -187,47 +178,47 @@ describe("Platforms", function () {
],
}

it("should resolve to best platform", function () {
platforms
.resolve(version, "osx")
.filename.should.be.exactly("test-3.3.1-darwin.dmg")
platforms
.resolve(version, "win32")
.filename.should.be.exactly("AtomSetup.exe")
platforms
.resolve(version, "linux_64")
.filename.should.be.exactly("atom-amd64.tar.gz")
platforms
.resolve(version, "linux_32")
.filename.should.be.exactly("atom-ia32.tar.gz")
platforms
.resolve(version, "linux_rpm_32")
.filename.should.be.exactly("atom-ia32.rpm")
platforms
.resolve(version, "linux_rpm_64")
.filename.should.be.exactly("atom-amd64.rpm")
platforms
.resolve(version, "linux_deb_32")
.filename.should.be.exactly("atom-ia32.deb")
platforms
.resolve(version, "linux_deb_64")
.filename.should.be.exactly("atom-amd64.deb")
test("should resolve to best platform", function () {
expect(platforms.resolve(version, "osx").filename).toEqual(
"test-3.3.1-darwin.dmg",
)
expect(platforms.resolve(version, "win32").filename).toEqual(
"AtomSetup.exe",
)
expect(platforms.resolve(version, "linux_64").filename).toEqual(
"atom-amd64.tar.gz",
)
expect(platforms.resolve(version, "linux_32").filename).toEqual(
"atom-ia32.tar.gz",
)
expect(platforms.resolve(version, "linux_rpm_32").filename).toEqual(
"atom-ia32.rpm",
)
expect(platforms.resolve(version, "linux_rpm_64").filename).toEqual(
"atom-amd64.rpm",
)
expect(platforms.resolve(version, "linux_deb_32").filename).toEqual(
"atom-ia32.deb",
)
expect(platforms.resolve(version, "linux_deb_64").filename).toEqual(
"atom-amd64.deb",
)
})

it("should resolve to best platform with a preferred filetype", function () {
platforms
.resolve(version, "osx", {
test("should resolve to best platform with a preferred filetype", function () {
expect(
platforms.resolve(version, "osx", {
filePreference: [".zip"],
})
.filename.should.be.exactly("test-3.3.1-darwin-x64.zip")
}).filename,
).toEqual("test-3.3.1-darwin-x64.zip")
})

it("should resolve to best platform with a wanted filetype", function () {
platforms
.resolve(version, "osx", {
test("should resolve to best platform with a wanted filetype", function () {
expect(
platforms.resolve(version, "osx", {
wanted: ".zip",
})
.filename.should.be.exactly("test-3.3.1-darwin-x64.zip")
}).filename,
).toEqual("test-3.3.1-darwin-x64.zip")
})
})
})
19 changes: 19 additions & 0 deletions __tests__/testing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var nuts = require("../lib")

var config = {
repository: "biw/awdao[uid wpaoduifuck",
token: process.env.GITHUB_TOKEN,
}

var instance = nuts.Nuts(config)
var app = nuts.createApp(config)

module.exports = {
app: app,
nuts: instance,
}

test("testing.js", () => {
// this is a blank test, need to refactor this file
expect(1).toEqual(1)
})
Loading