Skip to content

Commit

Permalink
Merge pull request #2 from georgeben/fix-codecoverage
Browse files Browse the repository at this point in the history
Fix code coverage
  • Loading branch information
georgeben committed Jun 21, 2019
2 parents 88d44f9 + 9bd93e8 commit 465430a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ng_universities",
"version": "1.0.0",
"version": "1.0.1",
"description": "A package to retrieve the list of universities in Nigeria approved by the Nigerian University Commission (NUC)",
"main": "index.js",
"scripts": {
Expand Down
46 changes: 43 additions & 3 deletions test/index.spec.js
Expand Up @@ -4,14 +4,54 @@ const expect = require('chai').expect
const path = require('path')

describe('index.js', function(){
let universities = []

before(function(done){
universities = JSON.parse(fs.readFileSync(path.join(__dirname, '../db/universities.json'), 'utf-8'))
// universities = JSON.stringify(universities)
done()
})

beforeEach(function(){
universities = JSON.stringify(universities)
universities = JSON.parse(universities)
})


it('smoke tests', function(){
expect(1).to.equal(1)
})

it('should return list of all universities', function(){
let universities = JSON.parse(fs.readFileSync(path.join(__dirname, '../db/universities.json'), 'utf-8'))
universities = JSON.stringify(universities)
expect(getUniversities()).to.deep.equal(universities)
expect(getUniversities()).to.deep.equal(JSON.stringify(universities))
})

it('should return the list of private universities', function(){
private_universities = JSON.stringify(universities.filter(function(item){
return item.type == "Private"
}))
expect(getUniversities("private")).to.deep.equal(private_universities)
})

it('should return the list of federal universities', function(){
federal_universities = JSON.stringify(universities.filter(function(item){
return item.type == "Federal"
}))
expect(getUniversities("federal")).to.deep.equal(federal_universities)
})

it('should return the list of state universities', function(){
state_universities = JSON.stringify(universities.filter(function(item){
return item.type == "State"
}))
expect(getUniversities("state")).to.deep.equal(state_universities)
})

it('should return the list of public universities', function(){
public_universities = JSON.stringify(universities.filter(function(item){
return item.type == "State" || item.type == "Federal"
}))
expect(getUniversities("public")).to.deep.equal(public_universities)
})

it('should throw an error if a wrong parameter for category is passed', function(){
Expand Down

0 comments on commit 465430a

Please sign in to comment.