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

Commit

Permalink
add some basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RealOrangeOne committed Dec 11, 2016
1 parent 130a5ee commit 151bc02
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"scripts": {
"prepublish": "npm run build",
"postinstall": "node src/haste.js",
"test": "npm run lint",
"lint": "eslint 'src/' 'test/' 'mock.js'",
"test": "npm run lint && npm run mocha",
"mocha": "mocha --require mock.js --bail 'tests/**/*.test.js'",
"lint": "eslint 'src/' 'tests/' 'mock.js'",
"build": "babel src --out-dir build"
},
"repository": {
Expand Down
2 changes: 2 additions & 0 deletions src/NativeModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,5 @@ _.forEach(Object.keys(mockNativeModules), function (mod) {
});

mockery.registerMock('NativeModules', mockNativeModules);

export default mockNativeModules;
16 changes: 16 additions & 0 deletions tests/globals.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { expect } from 'chai';


describe('Globals', function () {
it('should have promise globally', function () {
expect(global.Promise).to.deep.equal(require('promise'));
});

it('should have promise globally', function () {
expect(global.regeneratorRuntime).to.deep.equal(require('regenerator-runtime/runtime'));
});

it('should be in dev', function () {
expect(global.__DEV__).to.be.true;
});
});
19 changes: 19 additions & 0 deletions tests/haste-map.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect } from 'chai';
import fs from 'fs';
import path from 'path';

const MAP_LOCATION = path.join(__dirname, '../haste-map.json');

describe('Haste Map', function () {
it('Should have one initially', function () {
const stat = fs.statSync(MAP_LOCATION);
expect(stat.isFile()).to.be.true;
});

it('should contain correct data', function () {
const HasteMap = require('../haste-map');
expect(HasteMap).to.have.all.keys('hasteMap', 'version');
expect(HasteMap.hasteMap).to.be.an('object');
expect(HasteMap.version).to.be.a('string');
});
});
18 changes: 18 additions & 0 deletions tests/native-modules.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { expect } from 'chai';
import NativeModules from '../src/NativeModules';

describe('Native Modules', function () {
it('Should be defined', function () {
expect(require('NativeModules')).to.deep.equal(NativeModules); // eslint-disable-line import/no-unresolved
expect(NativeModules).to.be.an('object');
});

describe('Single Modules', function () {
Object.keys(NativeModules).forEach(function (mod) {
it('should require ' + mod, function () {
expect(require(mod)).to.deep.equal(NativeModules[mod]);
expect(require(mod)).to.be.an('object');
});
});
});
});
9 changes: 9 additions & 0 deletions tests/react-native-version.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { expect } from 'chai';


describe('React-Native version', function () {
it('should return correct version', function () {
const version = require('../src/react-native-version');
expect(version).to.be.a('string');
});
});

0 comments on commit 151bc02

Please sign in to comment.