forked from bkkhack/hackmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic unit test infrastructure (bkkhack#33)
* add basic unit test infrastructure * add jest config and tests
- Loading branch information
Showing
5 changed files
with
83 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dist/ | ||
node_modules/ | ||
coverage/ | ||
*.log |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- "node" | ||
cache: | ||
directories: | ||
- "node_modules" | ||
script: npm run continuous-integration |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import Vue from 'vue' | ||
import RightComponent from '../../src/components/Right.vue' | ||
|
||
function mount(Component, props) { | ||
const Constructor = Vue.extend(Component) | ||
const component = new Constructor({ propsData: props }).$mount() | ||
return component | ||
} | ||
|
||
describe('RightComponent', () => { | ||
let props; | ||
|
||
beforeEach(function() { | ||
props = { | ||
selectedProject: { | ||
id: 1, | ||
title: 'Doomsday Device', | ||
description: 'Time to take over the world!', | ||
username: 'Dr_Horrible' | ||
}, | ||
username: 'Dr_Horrible' | ||
} | ||
}) | ||
|
||
it('shows the edit button when the selected project belongs to the logged-in user', () => { | ||
props.selectedProject.username = "Dr_Horrible" | ||
props.username = "Dr_Horrible" | ||
|
||
const sidebar = mount(RightComponent, props) | ||
|
||
const editButton = sidebar.$el.querySelector(".edit-button") | ||
expect(editButton).not.toBeNull() | ||
}) | ||
|
||
it('hides the edit button when the selected project does not belong to the logged-in user', () => { | ||
props.selectedProject.username = "Dr_Horrible" | ||
props.username = "Captain_Hammer" | ||
|
||
const sidebar = mount(RightComponent, props) | ||
|
||
const editButton = sidebar.$el.querySelector(".edit-button") | ||
expect(editButton).toBeNull() | ||
}) | ||
}) | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import serialization from '../src/github-serialization.js' | ||
|
||
describe('serialization', () => { | ||
it('should deserialize a github comment to a project object', () => { | ||
let comment = { | ||
id: 555, | ||
body: 'doomsday device\r\ntime to take over the world!<!--0.8,0.2-->', | ||
user: { | ||
login: 'Bob', | ||
avatar_url: 'http://www.example.com/bob.jpg' | ||
} | ||
} | ||
let project = serialization.deserializeCommentToProject(comment) | ||
expect(project.title).toEqual('doomsday device') | ||
}) | ||
}) | ||
|