Created
February 24, 2015 15:43
-
-
Save MatthewBarker/e1e4c8157449f3c8531c to your computer and use it in GitHub Desktop.
Jasmine 2.2.0 + Require.js: How to use Jasmine's boot file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global describe , it, expect*/ | |
describe('Array', function () { | |
'use strict'; | |
describe('.push()', function () { | |
it('should append a value', function () { | |
var arr = []; | |
arr.push('foo'); | |
arr.push('bar'); | |
expect(arr[0]).toBe('foo'); | |
expect(arr[1]).toBe('bar'); | |
}); | |
it('should return the length', function () { | |
var arr = [], | |
n = arr.push('foo'); | |
expect(n).toBe(1); | |
n = arr.push('bar'); | |
expect(n).toBe(2); | |
}); | |
describe('with many arguments', function () { | |
it('should add the values', function () { | |
var arr = []; | |
arr.push('foo', 'bar'); | |
expect(arr[0]).toBe('foo'); | |
expect(arr[1]).toBe('bar'); | |
}); | |
}); | |
}); | |
describe('.unshift()', function () { | |
it('should prepend a value', function () { | |
var arr = [1, 2, 3]; | |
arr.unshift('foo'); | |
expect(arr[0]).toBe('foo'); | |
expect(arr[1]).toBe(1); | |
}); | |
it('should return the length', function () { | |
var arr = [], | |
n = arr.unshift('foo'); | |
expect(n).toBe(1); | |
n = arr.unshift('bar'); | |
expect(n).toBe(2); | |
}); | |
describe('with many arguments', function () { | |
it('should add the values', function () { | |
var arr = []; | |
arr.unshift('foo', 'bar'); | |
expect(arr[0]).toBe('foo'); | |
expect(arr[1]).toBe('bar'); | |
}); | |
}); | |
}); | |
describe('.pop()', function () { | |
it('should remove and return the last value', function () { | |
var arr = [1, 2, 3]; | |
expect(arr.pop()).toBe(3); | |
expect(arr.pop()).toBe(2); | |
expect(arr.length).toBe(1); | |
}); | |
}); | |
describe('.shift()', function () { | |
it('should remove and return the first value', function () { | |
var arr = [1, 2, 3]; | |
expect(arr.shift()).toBe(1); | |
expect(arr.shift()).toBe(2); | |
expect(arr.length).toBe(1); | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var require = { | |
paths: { | |
'jasmine': 'lib/jasmine-2.2.0/jasmine', | |
'jasmine-html': 'lib/jasmine-2.2.0/jasmine-html', | |
'boot': 'lib/jasmine-2.2.0/boot' | |
}, | |
shim: { | |
'jasmine': { | |
exports: 'window.jasmineRequire' | |
}, | |
'jasmine-html': { | |
deps: ['jasmine'], | |
exports: 'window.jasmineRequire' | |
}, | |
'boot': { | |
deps: ['jasmine', 'jasmine-html'], | |
exports: 'window.jasmineRequire' | |
} | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Test Runner</title> | |
<link rel="stylesheet" type="text/css" href="lib/jasmine-2.2.0/jasmine.css"> | |
</head> | |
<body> | |
<script src="require.config.js"></script> | |
<script data-main="test-runner" src="../src/bower-modules/require/require.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jslint browser: true*/ | |
/*global require*/ | |
require(['boot'], function () { | |
'use strict'; | |
require(['spec/array-spec'], function () { | |
window.onload(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment