Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
test(runner): migrates to jasmine
Browse files Browse the repository at this point in the history
  • Loading branch information
mdreizin committed Nov 24, 2015
1 parent cca3056 commit 0069f3f
Show file tree
Hide file tree
Showing 19 changed files with 137 additions and 132 deletions.
13 changes: 13 additions & 0 deletions jasmine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

var Jasmine = require('jasmine'),
SpecReporter = require('jasmine-spec-reporter');

var jasmine = new Jasmine();

jasmine.configureDefaultReporter({
print: function() {}
});
jasmine.addReporter(new SpecReporter());
jasmine.loadConfigFile(process.env.JASMINE_CONFIG_PATH);
jasmine.execute();
6 changes: 6 additions & 0 deletions jasmine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"spec_dir": "test",
"spec_files": [
"**/*[sS]pec.js"
]
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"clean": "rm -rf ./coverage",
"lint": "eslint --cache ./",
"pretest": "npm run lint",
"test": "mocha --full-trace --check-leaks -u exports -R spec",
"test": "JASMINE_CONFIG_PATH=./jasmine.json node ./jasmine.js",
"precover": "npm run lint",
"cover": "istanbul cover _mocha -- --full-trace --check-leaks -u exports -R spec",
"cover": "istanbul cover jasmine JASMINE_CONFIG_PATH=./jasmine.json",
"codeclimate": "codeclimate-test-reporter < ./coverage/lcov.info",
"doc": "gulp docs",
"postpublish": "publish-latest -a 'package.json README.md docs/API.md'",
Expand Down Expand Up @@ -43,7 +43,8 @@
"gulp-concat": "^2.5.2",
"gulp-jsdoc-to-markdown": "^1.1.1",
"istanbul": "^0.4.0",
"mocha": "^2.3.3",
"jasmine": "^2.3.2",
"jasmine-spec-reporter": "^2.4.0",
"publish-latest": "^1.1.2",
"run-sequence": "^1.1.0",
"semantic-release": "^4.3.5",
Expand Down
2 changes: 1 addition & 1 deletion test/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"env": {
"mocha": true
"jasmine": true
}
}
9 changes: 4 additions & 5 deletions test/config.spec.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
'use strict';

var expect = require('expect.js'),
Config = require('../lib/config');
var Config = require('../lib/config');

describe('Config', function () {
context('#ctor()', function() {
describe('#ctor()', function() {
it('should create config', function() {
var config = new Config();

expect(config).to.be.an(Config);
expect(config instanceof Config).toBeTruthy();

['extend', 'merge', 'defaults', 'toObject', 'clone'].forEach(function(name) {
expect(config[name]).to.be.an(Function);
expect(typeof config[name] === 'function').toBeTruthy();
});
});
});
Expand Down
11 changes: 5 additions & 6 deletions test/configCloneMixin.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

var expect = require('expect.js'),
Config = require('../lib/config');
var Config = require('../lib/config');

describe('ConfigCloneMixin', function () {
context('#clone()', function() {
describe('#clone()', function() {
it('should return clone of `Config`', function() {
var config = new Config();

Expand All @@ -14,9 +13,9 @@ describe('ConfigCloneMixin', function () {

var clone = config.clone();

expect(config).not.to.be(clone);
expect(clone).to.be.a(Config);
expect(config.toObject()).to.eql({
expect(config).not.toBe(clone);
expect(clone instanceof Config).toBeTruthy();
expect(config.toObject()).toEqual({
foo: 'foo1'
});
});
Expand Down
9 changes: 4 additions & 5 deletions test/configDefaultsMixin.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict';

var expect = require('expect.js'),
Config = require('../lib/config');
var Config = require('../lib/config');

describe('ConfigDefaultsMixin', function () {
context('#defaults()', function() {
describe('#defaults()', function() {
it('should add missing `options`', function() {
var config = new Config(),
date1 = new Date(),
Expand All @@ -18,14 +17,14 @@ describe('ConfigDefaultsMixin', function () {
bar: ['bar2'],
date: date2
}, function() {
expect(this).to.be(config);
expect(this).toBe(config);

return {
foo: 'foo2'
};
});

expect(config.toObject()).to.eql({
expect(config.toObject()).toEqual({
foo: 'foo1',
bar: ['bar2'],
date: date1
Expand Down
21 changes: 10 additions & 11 deletions test/configEnvironment.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use strict';

var expect = require('expect.js'),
ConfigEnvironment = require('../lib/configEnvironment');
var ConfigEnvironment = require('../lib/configEnvironment');

describe('ConfigEnvironment', function () {
var configEnvironment;

context('#value()', function() {
describe('#value()', function() {
beforeEach(function() {
process.env.WEBPACK_ENV = 'foo';
process.env.NODE_ENV = 'bar';
Expand All @@ -20,25 +19,25 @@ describe('ConfigEnvironment', function () {
});

it('should return `process.env.WEBPACK_ENV`', function() {
expect(configEnvironment.get('WEBPACK_ENV')).to.eql('foo');
expect(configEnvironment.get('WEBPACK_ENV')).toEqual('foo');
});

it('should return `process.env.NODE_ENV`', function() {
expect(configEnvironment.get('NODE_ENV')).to.eql('bar');
expect(configEnvironment.get('NODE_ENV')).toEqual('bar');
});

it('should return `env`', function() {
expect(configEnvironment.get('env')).to.eql('foo');
expect(configEnvironment.get('env')).toEqual('foo');
});
});

context('#add()', function() {
describe('#add()', function() {
it('should add custom values', function() {
configEnvironment.set({
rev: 1
});

expect(configEnvironment.get('rev')).to.eql(1);
expect(configEnvironment.get('rev')).toEqual(1);
});

it('should override existing values', function() {
Expand All @@ -47,9 +46,9 @@ describe('ConfigEnvironment', function () {
NODE_ENV: 2 // eslint-disable-line
});

expect(configEnvironment.get('WEBPACK_ENV')).to.eql(1);
expect(configEnvironment.get('NODE_ENV')).to.eql(2);
expect(configEnvironment.get('env')).to.eql(1);
expect(configEnvironment.get('WEBPACK_ENV')).toEqual(1);
expect(configEnvironment.get('NODE_ENV')).toEqual(2);
expect(configEnvironment.get('env')).toEqual(1);
});
});
});
23 changes: 11 additions & 12 deletions test/configExtendMixin.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

var expect = require('expect.js'),
webpack = require('webpack'),
var webpack = require('webpack'),
Config = require('../lib/config'),
ConfigFactory = require('../lib/configFactory'),
ConfigLoader = require('../lib/configLoader'),
Expand All @@ -20,13 +19,13 @@ describe('ConfigExtendMixin', function () {

Config.visitor = configVisitor;

context('#extend()', function() {
describe('#extend()', function() {
it('should extend via `String`', function() {
var config = new Config();

config.extend('./test/fixtures/webpack.5.config.js');

expect(config.toObject()).to.eql({
expect(config.toObject()).toEqual({
debug: false,
plugins: [
new webpack.optimize.UglifyJsPlugin(),
Expand All @@ -47,7 +46,7 @@ describe('ConfigExtendMixin', function () {
'./test/fixtures/webpack.5.config.js'
]);

expect(config.toObject()).to.eql({
expect(config.toObject()).toEqual({
debug: false,
plugins: [
new webpack.optimize.UglifyJsPlugin(),
Expand All @@ -72,7 +71,7 @@ describe('ConfigExtendMixin', function () {
'./test/fixtures/webpack.5.config.js': configTransform
});

expect(config.toObject()).to.eql({
expect(config.toObject()).toEqual({
debug: false,
plugins: [
new webpack.optimize.UglifyJsPlugin(),
Expand All @@ -94,7 +93,7 @@ describe('ConfigExtendMixin', function () {
'./test/fixtures/webpack.6.config.js': false
});

expect(config.toObject()).to.eql({
expect(config.toObject()).toEqual({
debug: false,
plugins: [
new webpack.optimize.UglifyJsPlugin(),
Expand All @@ -112,8 +111,8 @@ describe('ConfigExtendMixin', function () {
var config = new Config();

function configTransform(x) {
expect(x).to.be.an(Config);
expect(this).to.be(config);
expect(x instanceof Config).toBeTruthy();
expect(this).toBe(config);

return x;
}
Expand All @@ -122,7 +121,7 @@ describe('ConfigExtendMixin', function () {
'./test/fixtures/webpack.6.config.js': configTransform
});

expect(config.toObject()).to.eql({
expect(config.toObject()).toEqual({
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(true)
]
Expand All @@ -142,7 +141,7 @@ describe('ConfigExtendMixin', function () {
'./test/fixtures/webpack.6.config.js': configTransform
});

expect(config.toObject()).to.eql({
expect(config.toObject()).toEqual({
debug: false
});
});
Expand All @@ -156,7 +155,7 @@ describe('ConfigExtendMixin', function () {
'./test/fixtures/webpack.6.config.js': configTransform
});

expect(config.toObject()).to.eql({});
expect(config.toObject()).toEqual({});
});
});
});
47 changes: 23 additions & 24 deletions test/configFactory.spec.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
'use strict';

var expect = require('expect.js'),
Config = require('../lib/config'),
var Config = require('../lib/config'),
ConfigFactory = require('../lib/configFactory');

describe('ConfigFactory', function () {
var configFactory = new ConfigFactory();

context('#create()', function() {
describe('#create()', function() {
it('should create `Config` from `Object`', function() {
var config = configFactory.create({
foo: 'foo1'
});

expect(config).to.be.a(Object);
expect(config).to.be.a(Config);
expect(config.toObject()).to.eql({
expect(typeof config === 'object').toBeTruthy();
expect(config instanceof Config).toBeTruthy();
expect(config.toObject()).toEqual({
foo: 'foo1'
});
});
Expand All @@ -25,10 +24,10 @@ describe('ConfigFactory', function () {
foo: 'foo1'
}]);

expect(configs).to.be.a(Array);
expect(configs).to.have.length(1);
expect(configs[0]).to.be.a(Config);
expect(configs[0].toObject()).to.eql({
expect(Array.isArray(configs)).toBeTruthy();
expect(configs.length).toEqual(1);
expect(configs[0] instanceof Config).toBeTruthy();
expect(configs[0].toObject()).toEqual({
foo: 'foo1'
});
});
Expand All @@ -40,9 +39,9 @@ describe('ConfigFactory', function () {
};
});

expect(config).to.be.a(Object);
expect(config).to.be.a(Config);
expect(config.toObject()).to.eql({
expect(typeof config === 'object').toBeTruthy();
expect(config instanceof Config).toBeTruthy();
expect(config.toObject()).toEqual({
foo: 'foo1'
});
});
Expand All @@ -54,10 +53,10 @@ describe('ConfigFactory', function () {
}];
});

expect(configs).to.be.a(Array);
expect(configs).to.have.length(1);
expect(configs[0]).to.be.a(Config);
expect(configs[0].toObject()).to.eql({
expect(Array.isArray(configs)).toBeTruthy();
expect(configs.length).toEqual(1);
expect(configs[0] instanceof Config).toBeTruthy();
expect(configs[0].toObject()).toEqual({
foo: 'foo1'
});
});
Expand All @@ -67,9 +66,9 @@ describe('ConfigFactory', function () {
foo: 'foo1'
}));

expect(config).to.be.a(Object);
expect(config).to.be.a(Config);
expect(config.toObject()).to.eql({
expect(typeof config === 'object').toBeTruthy();
expect(config instanceof Config).toBeTruthy();
expect(config.toObject()).toEqual({
foo: 'foo1'
});
});
Expand All @@ -79,10 +78,10 @@ describe('ConfigFactory', function () {
foo: 'foo1'
})]);

expect(configs).to.be.a(Array);
expect(configs).to.have.length(1);
expect(configs[0]).to.be.a(Config);
expect(configs[0].toObject()).to.eql({
expect(Array.isArray(configs)).toBeTruthy();
expect(configs.length).toEqual(1);
expect(configs[0] instanceof Config).toBeTruthy();
expect(configs[0].toObject()).toEqual({
foo: 'foo1'
});
});
Expand Down
Loading

0 comments on commit 0069f3f

Please sign in to comment.