import {expect} from 'chai'
import mock from 'mock-require'
import stringify from 'json-stable-stringify'

mock('../../src/models/load-area', require('../mocks/load-area.mock'))
const Study = require('../../src/models/study')

describe('Study', () => {
	it('holds an area of study for a student', () => {
		let csci = new Study({type: 'major', name: 'Computer Science', revision: '2014-15'})

		let {path, type, name, revision, data} = csci

		expect(path).to.equal('majors/computer-science/2014-15')
		expect(type).to.equal('major')
		expect(name).to.equal('Computer Science')
		expect(revision).to.equal('2014-15')
		expect(data).to.be.an.instanceof(Promise)
	})

	it('can turn into JSON', () => {
		let csci = new Study({type: 'major', name: 'Computer Science', revision: '2014-15'})
		let result = stringify(csci)

		expect(JSON.parse(result)).to.deep.equal({
			name: 'Computer Science',
			path: 'majors/computer-science/2014-15',
			revision: '2014-15',
			type: 'major',
			source: '',
		})
	})
})

@@ -392,123 +392,20 @@
 %0A%0A%09%09
-let %7Bpath, type, name, revision, data%7D = csci%0A%0A%09%09expect(path).to.equal('majors/computer-science/2014-15')%0A%09%09
 expect(
+csci.
 type
@@ -433,16 +433,21 @@
 %09expect(
+csci.
 name).to
@@ -482,16 +482,21 @@
 %09expect(
+csci.
 revision
@@ -526,16 +526,21 @@
 %09expect(
+csci.
 data).to
@@ -769,16 +769,16 @@
 equal(%7B%0A
+
 %09%09%09name:
@@ -802,52 +802,8 @@
 e',%0A
-%09%09%09path: 'majors/computer-science/2014-15',%0A
 %09%09%09r

fix Study tests