1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 16:56:40 +03:00
vimr/NvimView/NvimViewTests/CellAttributesCollectionTest.swift
2018-08-29 08:40:01 +02:00

68 lines
2.2 KiB
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
import XCTest
import Nimble
@testable import NvimView
class CellAttributesCollectionTest: XCTestCase {
func testSetDefaultAttributes() {
let attrs = CellAttributes(
fontTrait: [], foreground: 1, background: 2, special: 3, reverse: true
)
self.cellAttributesCollection.set(attributes: attrs, for: 0)
expect(self.cellAttributesCollection.defaultAttributes)
.to(equal(attrs))
}
func testSetAndGetAttributes() {
let attrs = CellAttributes(
fontTrait: [], foreground: 1, background: 2, special: 3, reverse: true
)
self.cellAttributesCollection.set(attributes: attrs, for: 1)
expect(self.cellAttributesCollection.attributes(of: 1))
.to(equal(attrs))
}
func testSetAndGetAttributesWithDefaults() {
let defaultAttrs = CellAttributes(
fontTrait: [], foreground: 10, background: 20, special: 30, reverse: true
)
self.cellAttributesCollection.set(attributes: defaultAttrs, for: 0)
var attrs = CellAttributes(
fontTrait: [], foreground: -1, background: 2, special: 3, reverse: true
)
self.cellAttributesCollection.set(attributes: attrs, for: 1)
expect(self.cellAttributesCollection.attributes(of: 1))
.to(equal(CellAttributes(
fontTrait: [], foreground: 10, background: 2, special: 3, reverse: true
)))
attrs = CellAttributes(
fontTrait: [], foreground: 1, background: -1, special: 3, reverse: true
)
self.cellAttributesCollection.set(attributes: attrs, for: 1)
expect(self.cellAttributesCollection.attributes(of: 1))
.to(equal(CellAttributes(
fontTrait: [], foreground: 1, background: 20, special: 3, reverse: true
)))
attrs = CellAttributes(
fontTrait: [], foreground: 1, background: -1, special: -1, reverse: true
)
self.cellAttributesCollection.set(attributes: attrs, for: 1)
expect(self.cellAttributesCollection.attributes(of: 1))
.to(equal(CellAttributes(
fontTrait: [], foreground: 1, background: 20, special: 30, reverse: true
)))
}
private let cellAttributesCollection = CellAttributesCollection()
}