public void SetupPage_PageHadDescription_DescriptionClearedButEnglishStillThere() { var contents = @"<div class='bloom-page'> <div class='pageDescription' lang='en'>hello</div> <div class='pageDescription' lang='fr'>bonjour</div> </div>" ; var dom = new XmlDocument(); dom.LoadXml(contents); BookStarter.SetupPage((XmlElement)dom.SafeSelectNodes("//div[contains(@class,'bloom-page')]")[0], _librarySettings.Object, "abc", "def"); //should remove the French (I don't see that we actually have any templates that have anything but English, but just in case) AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//div[contains(@class, 'pageDescription') and @lang != 'en']", 0); //should leave English as a placeholder AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//div[contains(@class, 'pageDescription') and not(normalize-space(.))]", 1); }
public void SetupPage_LanguageSettingsHaveChanged_LangAttributesUpdated() { var contents = @"<div class='bloom-page'> <div class='bloom-translationGroup' data-book='foo'> <div class='bloom-editable' lang='en'></div> <div class='bloom-editable' lang='en'></div> <div class='bloom-editable' lang='en'></div> </div> </div>" ; var dom = new XmlDocument(); dom.LoadXml(contents); BookStarter.SetupPage((XmlElement)dom.SafeSelectNodes("//div[contains(@class,'bloom-page')]")[0], _librarySettings.Object, "abc", "def"); AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo']/div[@lang='fr']", 1); AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo']/div[@lang='es']", 1); AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//div[@data-book='foo']/div[@lang='xyz']", 1); }