Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test fixture patching and move all fixture to json #107

Merged
merged 2 commits into from Sep 17, 2016

Conversation

dinoboff
Copy link
Contributor

@dinoboff dinoboff commented Sep 17, 2016

Most fixture data should be defined in "test/fixtures.json", with its data used
to set the default firebase data for a test.

Your tests should reset the firebase before running, using
test/utils.js#setFirebaseData(somePatchToBaseData). e.g:

const utils = require('./utils.js');

describe('events', function() {

  beforeEach(function() {
    utils.setFirebaseData();
  });

});

To retrieve fixture data, you can use test/utils.js#fixtures(somePath); e.g.:

const utils = require('./utils.js');

describe('auth', function() {
  let chris;

  beforeEach(function() {
    chris = utils.fixtures('auth/users/google:chris');

    // set the database with chris not registered
    utils.setFirebaseData({
      auth: {
        publicIds: {chris: undefined},
        usedPublicIds: {chris: undefined},
        users: {'google:chris': undefined}
      }
    });
  });

  it('should let a user register', function() {
    // todo
  })

});

Returned values cannot be corrupted by a previous test and will always reflect
the data set in "tests/fixtures.json".

You can use test/utils.js#auth to authenticate with one of the fixture
registered users:

  • auth.admin (admin);
  • auth.chris alias for auth.admin;
  • auth.alice (premium, can create event and has an "alice-event" event setup);
  • auth.bob (participant of "alice-event" event);
  • auth.emma (only registered - to test non-participant access to event).

They can used with targaryen tests:

expect(utils.auth.chris).can.read.path('classMentors/events');

Thoses object cannot be corrupted by previous tests.

Type data are set in the json file. To test the rules related to the creation of the data; test can delete a node and try add it again with write/patch operation.

Also rename singpath-play-export.json since it’s does’t countain exported data anymore.
Merge main and database package.json for faster travis setup.
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling a9902e0 on dinoboff:refine-rules-test into * on singpath:master*.

@dinoboff dinoboff merged commit ee70037 into singpath:master Sep 17, 2016
@dinoboff
Copy link
Contributor Author

@SingaporeClouds I added the rules tests to travis and to make travis setup faster, I merged the rules package.json with the main one.

To test the rules:

npm run test:rules

or with mocha installed globally:

npm install -g mocha
cd database/
mocha 

@dinoboff dinoboff deleted the refine-rules-test branch October 3, 2016 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants