Utils = require '../src/flux/models/utils' describe "quoted text", -> it "should be correct for a google calendar invite", -> body = """

Recruiting Email Weekly Blastoff

Turn those cold leads into phone screens! You can make this go super fast by queueing up your drafts before hand and just sending them out during this time.
When
Fri Feb 27, 2015 5pm – 5:30pm Pacific Time
Calendar
Ben Gotow
Who
Michael Grinich - organizer
Kartik Talwar
team
Rob McQueen
Evan Morikawa
Christine Spang
Karim Hamidou
nilas.com@allusers.d.calendar.google.com
Makala Keys
Eben Freeman
Jennie Lees
Ben Gotow
Kavya Joshi

Going?    - -     

Invitation from Google Calendar

You are receiving this email at the account ben@nilas.com because you are subscribed for invitations on calendar Ben Gotow.

To stop receiving these emails, please log in to https://www.google.com/calendar/ and change your notification settings for this calendar.

""" expect(Utils.containsQuotedText(body)).toBe(false) it "should be correct when email contains

tags", -> body = """

Hi Ben

Please goto the Workspaces Console > Directories.

Then, select the Directory and "Deregister".  After you deregister the Directory from Workspaces, you should then be able to goto Directory Services and remove the Directory.

Ben

""" expect(Utils.containsQuotedText(body)).toBe(false) expect(Utils.withoutQuotedText(body)).toBe(body) describe "subjectWithPrefix", -> it "should replace an existing Re:", -> expect(Utils.subjectWithPrefix("Re: Test Case", "Fwd:")).toEqual("Fwd: Test Case") it "should replace an existing re:", -> expect(Utils.subjectWithPrefix("re: Test Case", "Fwd:")).toEqual("Fwd: Test Case") it "should replace an existing Fwd:", -> expect(Utils.subjectWithPrefix("Fwd: Test Case", "Re:")).toEqual("Re: Test Case") it "should replace an existing fwd:", -> expect(Utils.subjectWithPrefix("fwd: Test Case", "Re:")).toEqual("Re: Test Case") it "should not replace Re: or Fwd: found embedded in the subject", -> expect(Utils.subjectWithPrefix("My questions are: 123", "Fwd:")).toEqual("Fwd: My questions are: 123") expect(Utils.subjectWithPrefix("My questions fwd: 123", "Fwd:")).toEqual("Fwd: My questions fwd: 123") it "should work if no existing prefix is present", -> expect(Utils.subjectWithPrefix("My questions", "Fwd:")).toEqual("Fwd: My questions")