<commit_before>import Quick
import Nimble
import rNews
import rNewsKit

class ArticleCellSpec: QuickSpec {
    override func spec() {
        var subject: ArticleCell! = nil
        var themeRepository: FakeThemeRepository! = nil

        let unupdatedArticle = Article(title: "title", link: nil, summary: "summary", author: "Rachel", published: NSDate(timeIntervalSinceReferenceDate: 0), updatedAt: nil, identifier: "", content: "content", read: false, estimatedReadingTime: 0, feed: nil, flags: [], enclosures: [])
        let readArticle = Article(title: "title", link: nil, summary: "summary", author: "Rachel", published: NSDate(timeIntervalSinceReferenceDate: 0), updatedAt: NSDate(timeIntervalSinceReferenceDate: 100000), identifier: "", content: "content", read: true, estimatedReadingTime: 0, feed: nil, flags: [], enclosures: [])

        beforeEach {
            subject = ArticleCell(style: .Default, reuseIdentifier: nil)
            themeRepository = FakeThemeRepository()
            subject.article = unupdatedArticle
            subject.themeRepository = themeRepository
        }

       describe("changing the theme") {
            beforeEach {
                themeRepository.theme = .Dark
            }

            it("updates each label") {
                expect(subject.title.textColor).to(equal(themeRepository.textColor))
                expect(subject.published.textColor).to(equal(themeRepository.textColor))
                expect(subject.author.textColor).to(equal(themeRepository.textColor))
                expect(subject.readingTime.textColor).to(equal(themeRepository.textColor))
            }

            it("changes the cell's background colors") {
                expect(subject.backgroundColor).to(equal(themeRepository.backgroundColor))
            }
        }

        it("should set the title label") {
            expect(subject.title.text).to(equal("title"))
        }

        it("should set the published/updated label") {
            let dateFormatter = NSDateFormatter()

            dateFormatter.timeStyle = .NoStyle
            dateFormatter.dateStyle = .ShortStyle
            dateFormatter.timeZone = NSCalendar.currentCalendar().timeZone

            expect(subject.published.text).to(equal(dateFormatter.stringFromDate(unupdatedArticle.published)))
        }

        it("should not show the estimated reading time") {
            expect(subject.readingTime.hidden).to(beTruthy())
        }

        it("should show the author") {
            expect(subject.author.text).to(equal("Rachel"))
        }

        it("should indicate that it's unread") {
            expect(subject.unread.unread).toNot(equal(0))
        }

        context("setting an read article") {
            beforeEach {
                subject.article = readArticle
            }

            it("should indicate that it's read") {
                expect(subject.unread.unread).to(equal(0))
            }
        }

        context("setting a decently long article") {
            beforeEach {
                subject.article = Article(title: "title", link: nil, summary: "summary", author: "Rachel", published: NSDate(timeIntervalSinceReferenceDate: 0), updatedAt: nil, identifier: "", content: "content", read: false, estimatedReadingTime: 15, feed: nil, flags: [], enclosures: [])
            }

            it("should show the estimated reading time") {
                expect(subject.readingTime.hidden).to(beFalsy())
                expect(subject.readingTime.text).to(equal("15 minutes"))
            }
        }

        context("setting an updated article") {
            beforeEach {
                subject.article = readArticle
            }

            it("should set the published/updated label") {
                let dateFormatter = NSDateFormatter()
<commit_msg>Fix test... oops<commit_after>import Quick
import Nimble
import rNews
import rNewsKit

class ArticleCellSpec: QuickSpec {
    override func spec() {
        var subject: ArticleCell! = nil
        var themeRepository: FakeThemeRepository! = nil

        let unupdatedArticle = Article(title: "title", link: nil, summary: "summary", author: "Rachel", published: NSDate(timeIntervalSinceReferenceDate: 0), updatedAt: nil, identifier: "", content: "content", read: false, estimatedReadingTime: 0, feed: nil, flags: [], enclosures: [])
        let readArticle = Article(title: "title", link: nil, summary: "summary", author: "Rachel", published: NSDate(timeIntervalSinceReferenceDate: 0), updatedAt: NSDate(timeIntervalSinceReferenceDate: 100000), identifier: "", content: "content", read: true, estimatedReadingTime: 0, feed: nil, flags: [], enclosures: [])

        beforeEach {
            subject = ArticleCell(style: .Default, reuseIdentifier: nil)
            themeRepository = FakeThemeRepository()
            subject.article = unupdatedArticle
            subject.themeRepository = themeRepository
        }

       describe("changing the theme") {
            beforeEach {
                themeRepository.theme = .Dark
            }

            it("updates each label") {
                expect(subject.title.textColor).to(equal(themeRepository.textColor))
                expect(subject.published.textColor).to(equal(themeRepository.textColor))
                expect(subject.author.textColor).to(equal(themeRepository.textColor))
                expect(subject.readingTime.textColor).to(equal(themeRepository.textColor))
            }

            it("changes the cell's background colors") {
                expect(subject.backgroundColor).to(equal(themeRepository.backgroundColor))
            }
        }

        it("should set the title label") {
            expect(subject.title.text).to(equal("title"))
        }

        it("should set the published/updated label") {
            let dateFormatter = NSDateFormatter()

            dateFormatter.timeStyle = .NoStyle
            dateFormatter.dateStyle = .ShortStyle
            dateFormatter.timeZone = NSCalendar.currentCalendar().timeZone

            expect(subject.published.text).to(equal(dateFormatter.stringFromDate(unupdatedArticle.published)))
        }

        it("should not show the estimated reading time") {
            expect(subject.readingTime.hidden).to(beTruthy())
        }

        it("should show the author") {
            expect(subject.author.text).to(equal("Rachel"))
        }

        it("should indicate that it's unread") {
            expect(subject.unread.unread).toNot(equal(0))
        }

        context("setting an read article") {
            beforeEach {
                subject.article = readArticle
            }

            it("should indicate that it's read") {
                expect(subject.unread.unread).to(equal(0))
            }
        }

        context("setting a decently long article") {
            beforeEach {
                subject.article = Article(title: "title", link: nil, summary: "summary", author: "Rachel", published: NSDate(timeIntervalSinceReferenceDate: 0), updatedAt: nil, identifier: "", content: "content", read: false, estimatedReadingTime: 15, feed: nil, flags: [], enclosures: [])
            }

            it("should show the estimated reading time") {
                expect(subject.readingTime.hidden).to(beFalsy())
                expect(subject.readingTime.text).to(equal("15 minutes to read"))
            }
        }

        context("setting an updated article") {
            beforeEach {
                subject.article = readArticle
            }

            it("should set the published/updated label") {
                let dateFormatter = NSDateFormatter()

{'fraction_non_alphanumeric': 0.11058638331365604, 'fraction_numerical': 0.0044601862783680965, 'mean_word_length': 2.409660107334526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5307308', 'n_tokens_mistral': 1985, 'n_tokens_neox': 1864, 'n_words': 432}