Skip to content

Commit

Permalink
Update: Tests and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
omgaz committed Oct 28, 2016
1 parent 2749340 commit b9b7353
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: node_js
node_js:
- "0.11"
- "4.6"
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "js-diff",
"version": "0.0.1",
"version": "0.0.2",
"description": "A recursive JavaScript object comparison script",
"main": "diff.js",
"dependencies": {
"karma": "~0.12.21",
"karma-jasmine": "~0.1.5",
"karma-phantomjs-launcher": "^0.1.4"
"dependencies": {},
"devDependencies": {
"jasmine-core": "^2.5.2",
"karma": "^1.3.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.2"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Running Karma Tests\" && ./node_modules/karma/bin/karma start karma.conf.js --single-run --browsers PhantomJS"
},
Expand Down
31 changes: 25 additions & 6 deletions tests/test-factory.test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
describe("TestFactoryTester", function() {
var f = TestFactory.testObject;

beforeEach(function(){
spyOn(f, 'init').andCallThrough();
spyOn(f, 'init').and.callThrough();
});

afterEach(function() {
f.reset();
});

it("should be able to initialize", function() {
expect(f.init).toBeDefined();
f.init();
expect(f.init).toHaveBeenCalled();
});

it("should initialise an empty object", function(){
f.init();
expect(typeof f.obj).toEqual("object");
Expand Down Expand Up @@ -43,4 +43,23 @@ describe("TestFactoryTester", function() {
expect(f.isEmpty()).toEqual(true);
expect(f.obj.firstName).toBeUndefined();
});
});

it("should add and remove nested objects", function(){
f.init();
f.add("company", {
name: "Acme",
location: "London"
});

expect(f.isEmpty()).toEqual(false);
expect(f.obj.company).toBeDefined();
expect(f.obj.company.name).toBeDefined();
expect(f.obj.company.name).toEqual("Acme");
expect(f.obj.company.location).toEqual("London");

f.remove("company");

expect(f.isEmpty()).toEqual(true);
expect(f.obj.company).toBeUndefined();
});
});

0 comments on commit b9b7353

Please sign in to comment.