You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

53 lines
1.5 KiB

import { BrowserWindow } from 'electron'
import Lightning from 'lib/lnd/lightning'
jest.mock('electron-store')
jest.mock('lib/lnd/subscribe/transactions')
jest.mock('lib/lnd/subscribe/invoices')
jest.mock('lib/lnd/subscribe/channelgraph')
describe('Lightning', function() {
describe('Constructor', () => {
beforeAll(() => (this.lightning = new Lightning()))
describe('initial values', () => {
it('should set the "mainWindow" property to null', () => {
expect(this.lightning.mainWindow).toBeNull()
})
it('should set the "lnd" property to null', () => {
expect(this.lightning.lnd).toBeNull()
})
it('should initialise the "subscriptions" object with null values', () => {
expect(this.lightning.subscriptions).toMatchObject({
channelGraph: null,
invoices: null,
transactions: null
})
})
})
})
describe('subscribe()', () => {
beforeAll(() => {
this.window = new BrowserWindow({})
this.lightning = new Lightning()
this.lightning.subscribe(this.window)
})
it('should assign the window to the "mainWindow" property', () => {
expect(this.lightning.mainWindow).toBe(this.window)
})
})
describe('unsubscribe()', () => {
beforeAll(() => {
this.lightning = new Lightning()
this.lightning.mainWindow = new BrowserWindow({})
this.lightning.unsubscribe()
})
it('should unassign the "mainWindow" property', () => {
expect(this.lightning.mainWindow).toBeNull()
})
})
})