Good afternoon and welcome to the William G. McGowan Theater located in the Washington, D.C. area, the National Archives building. Excuse me, I'm Doug Swanson, visitor services manager for the National Archives Museum and producer for the Noontime Lecture Series. On behalf of David Ferriero Archivist of the United States, I'm pleased that you could join us for this afternoon's program, whether you are here in the theater or joining us through Facebook or YouTube. Before we hear from Julie Desjardins about her new book, American Queenmaker, How Missy Maloney Brought Women Into Politics, I'd like to tell you about two other programs coming up here on Thursday, January 23rd at noon. Historian Kathy Pice will discuss her book, Information Hunters, when librarian soldiers and spies banded together in World War II Europe. Her work reveals how book and document collecting became part of intelligence gathering, military planning, and post-war reconstruction. At 7 p.m. we will host a screening of One Woman, One Vote in honor of the 25th anniversary of that PBS documentary. The film documents the 70-year struggle for women's suffrage that culminated in the passing of the 19th Amendment. To keep informed about events throughout the year, check our website, www.archives.gov. Or sign up at the table outside the theater to get email updates. You'll also find information about other National Archives programs and activities. Another way to get more involved with the National Archives is to become a member of the National Archives Foundation. The Foundation supports the work of the agency, especially its education and outreach programs. Check out their website, archivesfoundation.org, to learn more about them and join online. Today's talk is part of a series of programs related to our special exhibit upstairs in the Lawrence F. O'Brien Gallery. Rightfully hers, American Women and the Vote. This exhibit is the cornerstone of our centennial celebration of the 19th Amendment, which secured women's right to vote in the Constitution. The decades-long fight for the vote in the 19th and early 20th centuries engaged large numbers of women in the political process and enforced the notion that women's voices needed to be heard. Missy Maloney supported the efforts of women who pursued their own careers and causes. And after the passage of the 19th Amendment, encouraged candidates to engage with and appeal to women directly. As our rightfully hers exhibit points out, the ratification of the 19th Amendment was not the end of the story. People like Missy Maloney continue to push for equal treatment in many areas of public life. To learn about Missy Maloney, journalist, magazine editor and political advisor, we'll now turn to Julie Desjardins. Julie is a historian of American women and gender who has taught and written extensively, particularly on the history of women in the professions. She has written several books including Women and the Historical Enterprise in America, Gender, Race and the Politics of Memory, The Madame Curie Complex, The Hidden History of Women in Science, Lillian Gilbreth, Redefining Domesticity, and Walter Camp Football and the Modern Man, along with pieces for blogs, journals, and Oxford's History of History writing. Professor Desjardins has spoken about her research on NPR and C-SPAN, book TV, and lectured around the country on the history of women in STEM fields. She has a PhD in American history from Brown University and was professor of history at Baruch College, City University of New York. She is also taught at Harvard University, Augsburg College, Hamlin University, McElster College, Simmons College, and Tufts University. Ladies and gentlemen, please welcome Julie Desjardins to the National Archives. Thank you so much for coming out. I know it's cold. I discovered the hard way coming from California that it's cold today. But thank you so much for having me and actually the timing is perfect for me personally because Missy Maloney comes out today. The book is coming out. And so I get to sort of introduce you to the American Queenmaker. So without further ado, because I'm a historian and I am not high tech, this is my visual for today. This is Missy Maloney. This is her son, William Brown Maloney V. And actually I have to tell you a little story about how I got this picture because one of the things that I wanted to do, you know, I thought, okay, the book's coming out. I want to have some great cover art. So I was looking for a really good visual. And so I was trying to see what was in the public domain. And the thing about Missy is she's very obscure. And I found this out about a lot of women that I've been studying in the progressive period. Many of them are very obscure. You can't find things about them. So I was looking for these pictures. I couldn't find a really good picture of Missy Maloney. And so I had to resort to one of two tactics that I tend to do with these women in the progressive period. The first is, of course, to look at her husband's name always. So I looked at, you know, Mrs. William Brown Maloney IV. And I found a couple more images that I liked, but I didn't find the ones that I really wanted. And so the second thing that I tend to do is I tend to go to eBay and I misspell these women's names. And it's amazing. I go and keyword search, misspell her name, and voila, here's the picture that I was able to get off eBay. This picture actually, the original is in, it's actually at the Library of Congress in the Arnold Dentley Collection. He was a very prominent photographer in San Francisco. And then around 1911 he actually went to New York and basically anybody who was anybody in New York got taken, you know, the picture was taken by him. And so it's not, it might say a little strange that this obscure woman had this famous photographer take a picture of her, but actually it wasn't so strange if you knew her at the time. Everybody knew her. Her name is Marie Mattingly Maloney. Everybody called her Missy. Everybody knew her. And she has very clearly fallen into obscurity, which is kind of what happens to a lot of the women in the progressive period. So in her case I think more than even most people, it's a real shame because this of course was a woman who was a pioneering journalist, as you just heard. She was a pioneering newspaper and magazine editor and I'll talk a lot more about that. She was really a PR maven in some ways. And I'm talking obviously before even television and God knows before social media. Very, very savvy manipulation of the media, this woman. And again I'll talk a little bit about that. I describe her as an unofficial advisor to US presidents and I'm talking even well before she could vote. Literally every US president in her adult life, she advised in some way, shape or form, which is of course the story you would have never guessed about this woman. She was a benefactress to artists, to scientists. Maybe today if she were alive, some of us might refer to her as a political pundit of some sort. I think of her as a real sort of rainmaker. That's kind of how I describe her. And I'm just getting started about this woman.  I mean she has really, really fallen into obscurity. And it's a shame, but I have to tell you, so when I decided I was going to do this book with Basic and they started to do all the marketing, they wanted to call her the most important woman you've never heard of. And that's how they started to refer to her on Amazon and everything else. And as a biographer who is staunchly protective of this woman, I kind of thought, you know, how would she have felt about this characterization? And I have to say I'm not sure she would have liked it. Not because she would have wanted to have been so well known for all of these decades and wasn't, and feels like she's been slighted. I think it's more a question of, in some ways, by very virtue of me talking about her and writing about her, I'm kind of blowing her cover a little bit. And this I have to explain. This is an interesting dynamic with women from the progressive period. I think Missy's obscurity is a little bit of her own design. Interesting dynamic. There's this great letter that I came across in her collection between her and another journalist named Channing Pollock. They had sort of written together when they were together at the Washington Post and knew each other over the decades. And in 1941, he wanted to write this article that outs her to the world and tells the world about all these things that Missy's been doing behind the scenes. And he kept showing her iterations of this article. He was going to get it published in Literary Digest. And she kept cutting out all the things that sort of outed all these things that she's done. She's like, oh, no, you don't want to mention that. You don't want to mention that. And finally, he gets it to where she thinks it's acceptable. And then right before it went to go get published, she totally put the kibosh on it. And so it never got published. And he sort of flabbergasted and he sort of joked with her. He said, you know, what is it going to take for me to be able to finally tell the world about Missy Maloney? And she kind of joked back. Well, she was joking, but not joking. Because she said, you know what, you can write about me when I'm dead. And left it at that. But actually, now that I've read that letter, I feel a little bit better, because she's been dead for about 75 years now. So I figured, fine. This is the time to out Missy. And actually, you know, I think the fact that we know so much more about the people and the things that she influenced more than we know about her probably says that on some level she might have succeeded in trying to accomplish what she was setting out to do.  I think for these kinds of women, if you had ambitions in the public sphere, you kind of had to have them in stealth. In some ways. And so Missy, in my mind, was one of the most effective people I've ever studied. And I've studied a lot of people from the progressive period. But of course, all of this is behind the scenes with her. And I think, you know, to get away with performing the public work and having the kind of what I would describe as de facto influence. You know, the kind that's suitable for men in these decades.  And so, you know, her very savvy understanding of people and her manipulation of the media and her shaping of politics and of culture, it almost had to look accidental. Like she could attribute it to other people. So Missy did this really, really successfully for decades. Which made me a little nervous about outing her. But ultimately for the purposes of a modern audience, specifically in 2020, I thought, you know what? I'm going to expose her deeds. And I'm going to expose her modus operandi. But I'm going to call it something else for a change. Leadership. Hmm. See, in 2020 I'm pretty convinced, really more than ever, that sort of the key to writing the political ship in this country is to perform the cultural work of reimagination. And if not necessarily of a leader, then maybe the traits of a leader as those that we in this culture have decided are feminine traits. And I say this because the social science tells us in many ways that these are the traits that are in fact the stuff of effective leadership. So knowing this to be true, I decided that Missy's role in 2020 should be as a facilitator of a really important conversation about effective leadership. And we desperately need it right now. And so long as this conversation is ultimately in the service of the social good and for the country, I actually think Missy would think it's okay that I'm outing her right now as this effective leader for modern times. And it's funny because one of the things she used to always say to people was that she was desperate to be useful. And in this way, I think I'm going to make her very, very useful. So that said, it was not readily apparent that I was going to use Missy this way for a very long time. But if you don't mind, I want to go back to when I first met Missy. You'll have to pardon the way I talk about her. It's a weird thing that biographers do because you're in their papers for years at a time. You start to feel like you know them. They're sort of your BFFs. I have had many conversations with Missy, which may sound not so healthy. But I do talk to Missy a lot. But I want to back up to when I first met Missy. And it was actually back in 2006, 2007 maybe. I was writing this very different book on the history of women in STEM fields called the Madame Curie Complex. And believe me, she's not a scientist. So I did not expect this woman to crop up out of nowhere. But I got to say she sort of popped up in the research because she was the benefactoress of the famed Nobel Prize-winning scientist Madame Curie. And I don't know if you guys know the story, but when the Curies discovered radium at the turn of the 20th century, they wanted to make this discovery readily available to anyone. And so they didn't patent the discovery. And this sounds like a wonderful thing, but what had happened was American chemical manufacturers sort of swooped in and perfected Curie's methods. And they started to charge such exorbitant prices for the radium that the Curies were literally priced out of the very element that they had discovered. And so they couldn't afford it. I think in 1920, a gram of radium was anywhere from $100,000 to $120,000 a gram or something like that.  And she literally raises the money within weeks to get Curie her radium. It was absolutely the most amazing thing I'd ever seen. So anyway, I'm seeing how she's doing this. She's so well connected. And I think, wow, how did she popularize this woman and make this woman's cause? She's a foreign woman, you know, this American cause.  But I didn't write about her yet because I had this other thing going on. I was working on a different book. This time it was about the industrial psychologist Lillian Gilberth. I don't know if you guys know about her, but from cheaper by the dozen fame. If you guys have seen the Steve Martin movies, they are basically based on books from after World War II. These were written by Gilberth's children. And I was writing this book on Lillian Gilberth. I'm going through the research. And Missy popped up again. This time it's interesting. They were sort of operating in the same social circles, in the same political circles, because Missy and Lillian were both affiliated with the Republican Party. Again, before they could vote. And Herbert Hoover loved both of these two women. They became really integral to his administration as advisors on women. I don't know if you realize. But the other thing about Lillian and Missy is that they designed kitchens for dual income families, as well as for single women, as an innovation of the Great Depression. And this was astounding to me, because the thing about the Great Depression, I don't know if you know anything about women and work during the Great Depression, but whether it was in the press or anywhere else, working women were really stigmatized for working. There was this assumption that women were taking men's jobs during the Great Depression if they were working, because, of course, so many men were out of jobs. This is, of course, to completely ignore the fact that most of these women were in underpaid jobs, seasonal jobs, feminized work sectors, you know, very much the pink collar trades. They weren't taking men's jobs. Men didn't want those jobs. But, of course, this is how they got stigmatized. And yet Missy pulled off this amazing coup, because in this era where no one wanted to really help working women, she was basically, under the aegis of being this, you know, this domestic magazine editor, she was facilitating women leaving the home, or at least making the home more efficient, so that they could go leave it and go pursue waged work. And I just found this astounding.  And I thought, what a savvy PR guru this woman was to pull this off during the Great Depression. And I was sort of in awe of her finding her very, very interesting, thinking maybe I'll write about her at some point, but I still didn't, because I had this other book that I wanted to write, and I really didn't expect her to pop up with this one, because this one was actually a biography of a man named Walter Camp, the father of American football. Why Missy would pop up in this project? I did not think she would. I have to say the reason why I was writing this book, even though I write about women and gender, I thought, you know, who better to tell the story about the crisis and American masculinity at the turn of the 20th century than to tell the story of Walter Camp?  So I'm researching this book, and I'm in Walter Camp's papers, and Missy pops up again. And I was astounded. This time she was serving as the editor of the New York Herald Tribune. She had a Sunday magazine there, and she was asking Walter Camp to write an article not just about football, but about football significance to American manhood. And this was stunning to me, because she was basically intuiting the cultural significance of football literally in real time in ways that I was, you know, decades after the fact. And she had this sort of, these cultural instincts, but she had them in real time. And by this point I am so astounded with all of these ways she was popping up and being sort of culturally relevant in all of these different theaters. She knew all of these prominent men and women, and there were all these different public theaters that she was doing all these things in, that now she's piqued my interest, and this is what I decided I was going to start to pursue the research about Missy Maloney. And, you know, I knew there were correspondence that she had written letters back and forth to Madame Curie, and they were housed at Columbia University, and I had used those letters to write about her. What I didn't realize, and I'm sort of embarrassed, because this is like, you know, the tactic I always do with progressive women, I had forgotten to look for papers under her husband's name. So I go to Columbia, and I finally get around to putting in her husband's name, and there was something like 28 boxes of her correspondence completely sitting there under her husband's name, and I had not thought to look there, so I'm a little embarrassed. But I eventually got to them. It was amazing. So her son, in 1961, deposited those papers. Her son, the little boy that's in the picture here, in 1961 he thought it was a good idea to leave his mother's papers there. A, because he had taught at Columbia, actually, for a little while. But I think, you know, he looked at these papers and said, wow, this is a treasure trove about really important great men of history. His mother had papers about any man who was anybody in New York and in D.C. in the first few decades of the 20th century.  She's talking to these men with regularity. Congressman, Supreme Court justices, cabinet secretaries, generals, editors, authors, film stars, athletes, you name it, Missy knew them. Talking back and forth and all of this correspondence is in this collection. And I have to tell you, I mean, I was reading these letters by men of consequence and the stories abound, like the story when she helped Goetzan Borglum get his federal funding to be able to build what we now know as Mount Rushmore. She helped with that behind the scenes. And then there were all of these pep talks to ambassadors who felt impotent in their roles overseas. Ambassadors like Alexander Kirk and Nicholas Roosevelt, they wrote her all the time asking for advice. And then there was her political consulting. Let's just call it what it was. It was political consulting at the time that she did for presidential candidates. It was really unbelievable. And of course, once they won the presidency, this political consulting extended into image consulting and all sorts of other consulting that she did for these men. And then there was, of course, her career development of very, very famous authors and I'm sure you guys know the names. People like Sinclair Lewis, J.A. Berry of Peter Pan fame, Robert Frost, any number of European men, I could go on and on and on. They wanted her advice. She helped them get an in in the literary world. So many stories about great men were in this collection. But actually there was also plenty of stories in that collection that were of interest to someone like me who looks for stories in other places. See, I was paying attention to the correspondence that the researchers were completely ignoring between Missy and women. And I have to say other than the collection of papers, they pulled out all the ones between her and Madame Curie and put those in a separate collection and everyone knew those papers. But no one was paying attention to these other ones that were between her and these other women. So I paid attention to those. And I figured, you know, whatever they contained, why weren't men using these papers? And I think it's because they assumed that maybe they would tell these personal stories but not official stories. And that's the stuff that history is made of. And they might tell sort of domestic stories but not the professional stories. And maybe they'll give some cultural insights but not political insights. I think a lot of people dismissed those papers as the stuff of trivia instead of the stuff of history. But that to me was to ignore all of the ways that lovers of influence get quietly pulled. So I tucked into those papers. I tucked into the whole collection for about three or four years. And I thought, you know what, I bet you there are stories here that are going to resonate for a modern audience. You know, ones about women's quiet influence, ones about the power of female friendships, and maybe even ones about dynamics of gender that I hadn't even thought about yet. What I didn't anticipate was finding dozens of these stories. And I joke with a lot of my friends. You know, they would say to me, how is it going studying that woman? And I'd say, you know, she's kind of like the forest gump of her day. You would not believe if you think of just stories that you know of from the turn of the 20th century that made the front page and even some of the stories that were a little bit, you know, deeper into the newspaper, she was quietly pulling lovers in many of these instances, but of course always behind a curtain. And she was pulling them younger than you would have expected, which is the amazing thing. Of course, well before she could vote. As a teenager, she had these amazing breaks. She actually, she was the one journalist who covered the return of the war hero, Admiral George Dewey when he returned from the Spanish-American War. He quietly got married to this divorcee, but no one knew about it except that Missy was there. So she reported on it. She was the first woman journalist to cover both the Democratic and the Republican national conventions in 1900. And what's interesting is she covered these conventions like no men were. I sort of argue that she practically invented this modern genre of political portraiture. Much more sort of humanized accounts. She broke news about candidates like William Jennings Bryant that no one else knew. She was the sole political correspondent covering Teddy Roosevelt when he was giving stump speeches out in Colorado in 1900. No other journalists were there at the time because quite frankly they were being shot at at some of these things. She was there. She was, it was unbelievable, the places I would not have expected to find her, but she was there. And if you sort of fast forward to World War I, she actually was covering the front lines. Many women journalists, of course, there were a few that went to Europe, but certainly didn't get that kind of access to the front lines. She was there, but she was also covering all these human interest stories that seemed more appropriate for women at the time. But she also had access to many of the royals who were in hiding, literally so that they wouldn't get killed. They trusted her. Meanwhile, while she's doing all of this news coverage, she was conceiving of the idea of the Junior Red Cross. I don't know that people realize that she's tied to that. She was raising money to clothe and feed European victims of war. And at this time, by this time her journalism was starting to become advocacy in ways that it wasn't for male journalists. She was the first domestic magazine editor to treat her readers, you know, women, presumably homemakers, like they were potential voters. And she did this by introducing them to presidential candidates even before they could vote. It's funny, there is a general named Leonard Wood. He was a war hero during the Spanish-American War. She tried to make him the woman's candidate of 1920. See, she saw suffrage coming. And so she tried to shape him that way and she would write about him in her domestic magazines to try to get women wanting to vote for him. It didn't go very far, unfortunately, because he was not chosen by the Republican Party to be their candidate. Warren Harding was. But she was a lot more successful eight years later when she turned Herbert Hoover into the woman's candidate. And he won the presidency. Now, there was no scientific polling in 1928. So we can't be very specific. But there's very compelling evidence to suggest that women made the difference for Herbert Hoover in 1928. And of course, Missy was very much part of that. She was also very, very good friends with Calvin Coolidge. And this is, of course, even before he was president and before he was vice president. But all the way back when he was the governor of Massachusetts, Missy recognized that the man needed some serious public relations help. You know, this was sort of the rise of the cult of personality. And for those of you who don't know, Calvin Coolidge was not exactly Mr. Charisma. She realized that he needed some help. And she was the one that figured out that his greatest PR asset was going to be his very charming wife, Grace Coolidge. So Missy didn't just help Grace Coolidge. She also went on to help Lou Henry Hoover. And she went on to help Eleanor Roosevelt in the 1930s become the modern prototypes of what we know as the American First Lady. And of course, this may seem like a strange statement because we know there were First Ladies before the 20th century. But the thing about it was the ones before this were not exactly the public or political figures that they became. Missy turned them into, at least in the press, into national hostesses, into role models for public consumption.  But there was this other unintended consequence because very slowly she started to make them politicized beings in their own right. It was very, very slow and gradual, but she helped this process along. By the time you get to Eleanor Roosevelt, she is a highly politicized First Lady. Really, I would consider the modern prototype of the First Lady. Missy helped this process in stealth. What else did she do? She brought European writers and artists to the United States and of course brought American artists and writers to stardom throughout the world, including women. Authors like Willa Cather, Edna Ferber, Fannie Hurst, Edna St. Vincent Millay, Kathleen Norris, Zona Gayle. I could go on and on and on. And this was in the 1920s primarily, which is significant because this is the decade of the lost generation of male authors, presumably defining American literary tastes. So Missy in this decade was paying women writers what she was paying male writers. She was literally paying Kathleen Norris for her serials, what she was paying Sinclair Lewis for his. And it was a lot of money. I'm talking $50,000 to $60,000 a serial to go into her magazine. So she does this and brings these women authors into public consciousness so that they too can start to define literary tastes in this modern era. And then of course there's all of her work in the service of science. She amazingly saw the brilliance of people like Nikola Tesla when no one else saw it. She of course saw the brilliance of Madame Curie. It's really astounding to me what she did for that woman because of course in 1920, literally this is a period when women and scientists, these were cultural oxymorons. There was this idea that women could not possibly have a scientific mind. And even though she had done lots of things before her husband died, Curie was really persona non grata in the scientific establishment once her husband died and she was a widow. A lot of what she was doing could not be attributed to anyone else once her husband was gone. Missy understood this and became her best advocate. It's really literally she threw one of the most successful campaigns on a scientist's behalf that we have ever seen in American history. Astounding. What else did Missy do? She helped ambassadors get chosen. She helped candidates get elected. She helped authors get published. She helped artists get funded even and especially in the years of the Great Depression when artists could make nothing. And this I say sort of as for better or worse, I'd also argue that in some way she established middle class norms of domesticity that continue to exist when she created something called the Better Homes for America movement. Does that sound familiar? Better Homes for America? Have people heard it? You probably did not know it was literally the brainchild of one woman. Missy. And you know this of course was not just about influencing individuals. This was about shaping whole American communities in ways that still reverberate. And I say this of course for better or worse. You know however you feel about middle class norms of domesticity. I almost forgot wanting Americans to be better informed about national, international affairs, political and social issues, across parties, across nations, across political ideologies. She also created this forum in 1930 called the Herald Tribune Forum on Current Problems. It's my guess that you've never heard of this forum but I promise you that throughout the 1930s it was the most important public forum literally our nation had at the time. The first one she had in 1930 was literally supposed to be for area club women in the New York metropolitan area. She was, I think there was supposed to be 50 women who showed up but she had this amazing speaker list because of course she knew everybody and it ended up that 1,500 people showed up for this event. So every year thereafter she had to start doing this annually. She moved it to the Waldorf Astoria because she needed the capacity and literally by the mid 1930s tens of thousands of people showed up not just audience members but actual public speakers. They all pitched up to this forum and it got so popular that she started to have to put the panels and the keynotes over the national airwaves. So she was also one of these pioneers in the use of radio I would argue. Anybody who had an opinion in the 1930s showed up to these forums. Walter Lippmann, the king of Belgium, FDR anybody of political or cultural import was asked to go there and attended for no other reason than because Missy invited them to come. She really knew a lot of people. They talked about everything fascism, marriage, drugs, democracy war of course. And pretty soon this list of speakers as impressive as it was pretty soon these big hitters became women. She had Madame Chenkai Shek, Eleanor Roosevelt, Francis Perkins, Amelia Earhart, I mean these are all names that we still know right. She gave these women a national public platform when public and feminine were still defined as antithetical. So the question for me was which of these stories was going to be the story to tell to a modern audience? And I have to be honest with you the question plagued me. I was overwhelmed by this woman and I figured there's so many cool stories to tell. Where do I start? One of the ones I wanted to tell was this story about American diplomacy as it sort of happens behind the scenes because of course Missy was not only a confidant to ambassadors and to American presidents but she was also a confidant to kings, queens, Romanoff princesses, Mussolini, hell his lover literally anybody who was anybody in the State Department for decades so I thought how about I tell a story about how diplomacy really happens behind the scenes through forging relationships. This is key with Missy. It's all about our ability to forge relationships. But then there was this other very compelling story I wanted to tell about American journalism which was obvious. I mean who better to tell that story than a woman who started at the Washington Post as a teenager. She was this pioneer of domestic magazines, the inventor of the Sunday newspaper magazine supplement. I still read one. She was a mentor to an untold number of women journalists not just the political fire brand Dorothy Thompson but Ruth Gerber and even I don't know if you know who Ann O'Hare McCormick was but she was the first woman to win a Pulitzer Prize in journalism at the New York Times in 1937. Missy mentored her as well. There was a whole narrative of the story of gender in journalism that literally could have taken up a book in and of itself. So there was that. And then I thought you know there's also a book here about really the power of Missy's female friendships. She became best friends with Madame Curie but that was literally just one of dozens of women who she helped and who helped her. She had these amazing networks not just in New York not just in DC but internationally. And she was pulling these lovers in American politics and journalism and setting all these cultural trends but there was this cast of women who were very quietly and unofficially helping her to do that. So that was a story I wanted to tell. She was very close friends with Washington insiders like Alice Roosevelt for example. I don't know if you know Mabel Willebrandt she was an assistant attorney general in the 20s who had cracked down on prohibition. Missy was very good friends with her. It's fascinating because even though Missy was a Republican always her whole life identified that way. She called on women friends in the Democratic Party all the time to make bipartisan change. People like Francis Perkins Molly Doosan and of course Eleanor Roosevelt many many times. They were all her loyal friends and collaborators really. So that's when I realized here's another interesting story that's very very relevant for 2020. The story about how female political operatives historically their methods and motivations to serve have often differed from men's. And Missy is honestly a case in point like no other but we've seen it all the time. Women historically and I think we see a little bit of this today they have tended to choose principal and people over party often times ideals over incumbency they have done this statistically speaking with more regularity than men. Is this a biological rule about women? Absolutely not. But Missy's story provides really interesting insight about why this often becomes the case. So so many sort of issues surrounding Missy so many things that were currently on my mind anyway and I was just overwhelmed. I didn't know what I wanted to privilege is going to be the main story about Missy. I thought how do I write about her with focus and yet pay attention to all the things that resonate with her in the here and now and I honestly didn't know so I started writing all of these book proposals they were all over the place I mean all over the place and then one night almost miraculously I found this laser like focus. The night was November 8th 2016 election night it's fascinating so many thoughts were sort of coming in my mind at the time and I was desperate to understand what was going on on election night and now obviously we all know I mean there were plenty of Americans who could envision a president in womanly form and of course I say this because Hillary Clinton had won the popular vote but there was a significant number of Americans who clearly could not imagine such a thing we all know I think most of us do that there were multiple reasons for Hillary Clinton not winning that election technicalities of the electoral college not being the least of them and then of course choose any of your pick of regional class cultural race divides that were being preyed upon at the time but I also think we have to be honest the gender element was also alive and well in 2016 whether it was holding Hillary to different moral standards or ragging on her appearance or accusing her of not being maternal enough or maybe being too maternal maybe even too grand maternal or deciding she was too nice no maybe too mean or just deciding that she couldn't physically hack it the stigma of gender was there now 2016 was also a very interesting year in my personal life because that was when I left academia in New York and picked up my family and moved to Silicon Valley where I learned also very very quickly that the gender dynamics in leadership in tech sort of smacky in the face there too for those of you who don't know in 2016 lots of things interesting things happened in Silicon Valley that was when Ellen Pauw had lost her sexual harassment case against the VC firm Kleiner Perkins this was when Susan Fowler was calling foul at Uber for sexual harassment and literally every woman I was meeting in the tech space had a story to tell about how these visionaries in tech and I'm talking men slavishly devoted to innovation were woefully not so innovative when it came to imagining women leaders in their midst and this is of course despite what the data tells us would happen if you let women lead it was the same blind spot in some ways that Wall Street men had when that one woman sitting in the board room sounded alarms about their risky behavior in 2008 and was ignored it's interesting I think Wall Street and Silicon Valley they have no mythology that venerates the risk averse or really any other enlightened leadership that women might bring to the table for that matter so here's what we know historically about women in leadership positions be it in politics or the board room when they've gotten the chance to be there women have tended to more often than men like I've already suggested choose principles over party often times issues over incumbency social good over pure profit I'm not saying that they do this naturally or they do this essentially or men can't do this but historically speaking they have done this more women are more likely to cross the aisle if it means getting something done maybe even listening to other points of view and making compromise if it means making some progress on something women bring soft skills to positions of power and they've honed these through their lived experience they are more likely to not lead hierarchically they tend to situate themselves in the middle of their networks they can communicate but also listen up, down to the side, back ways really the middle of your network is this perfect vantage point from which to hear multiple points of view and to also connect people within your network who might not have found each other if you weren't smack in the middle connecting them for them women are more likely to bring their roles as parents as citizens to bear on their work in positions of power what about this don't we need right now this brand of leading was Missy's in spades and it's effective we've done lots of research to show it's effective but it's not always acknowledged because of course in Missy's case it was never about her it's about making the people around you shine and be effective are women more naturally inclined to lead this way no I know men who lead this way but the problem is that in our culture we imagine this way of being as a sort of feminine modus operandi and not as leadership which of course is all of this masculine connotation in our culture so this is how I was going to use Missy I decided that she's going to have something to say on this conversation and so I describe her as this American queen maker and I mean this in lots of different ways and it's my hope that by introducing her to people right now in 2020 this is going to start to facilitate some conversations about her kind of queen making and her way of leading because we really need it now in 2020 so I want to thank you for having me thank you for letting me introduce you to Missy I'm really hoping that by talking about her in this way she may really serve her most useful function yet so thank you for having me is there anyone who has any questions who wants to yeah if anyone has a question feel free to go to the microphone anyone do you mind going to the mic just because I think they have to pick it up on the microphone thanks well thank you for covering this history this remarkable person has been so fascinating it's been a pleasure many women who are invading a public space particularly in that point in history kind of faced being in kind of pooled between two worlds and as I was listening to you speak about Missy's invention of the norms of middle class domesticity it seemed to be in tension with some of the other people she promoted ideas she promoted and values and I was wondering if you could talk a little bit more about that maybe pick out a couple of those tensions that you found and what you might know about how she perceived those tensions if she did she doesn't talk about those tensions and it's very difficult as a historian to try to figure out Missy was sort of subverting these norms of domesticity but doing it in a way as this sort of she as a domestic editor an editor of domestic magazines she was trying to look like this again I call her Martha Stewart of her day but she's subverting those norms I can't tell you how many times I've seen this with women of this period they're saying they're doing this because this is the socially acceptable thing to be doing but quietly they're subverting that and so in her case one of the ways she became such a successful editor was that she was at a domestic magazine that's appropriate because she's giving domestic tips to home makers that's an acceptable thing but then quietly she starts to publish these articles here's who you should vote for when you start to vote and here's how you can make your house more efficient so that you can go do these other things she was actually there were articles in the delineator which is this domestic magazine about you know here's maybe some ways you could start to apply for college little sort of subversive things but under the guise of a domestic magazine and there is this push pull and the way that she think of her as such a PR guru is because she was able to pull it off without too many people being critical of her and in some ways the ways that she made this change was to look like she wasn't doing anything threatening right and so for example you know this is of course the 100th anniversary of the passing of suffrage Missy I argue was a very effective suffragist without being a suffragist she was not she would not have told you that she was a suffragist she was not affiliated with the NAWSA nothing like that but one of the things she would do is that she would work on women getting politicized quietly through the eages of this domestic magazine and so in some ways she was kind of more effective than the women that were clamoring loudly really for suffrage to have passed you needed sort of the one two punch you needed the women who were out there making what they called suffrage noise and were being radical and throwing asbestos coils into the White House trees and all that stuff and going on hunger strikes but then you also needed the women who very quietly were getting in with the politicians and making nice and that's what Missy looked to be doing while she was also sending these subversive messages and in that way she had a very savvy understanding of public relations and really had her finger on the pulse of culture in ways that I talk about in the book most men didn't quite understand because they didn't need to and it's not just her there's a couple women that I've I talk about Lillian Gilbert Lillian Gilbert understood a lot of those things too there's some women in this progressive period who understand that the persona they have to take on they have to take on this non-threatening persona to be able to quietly do these other things and that's why I think they've been so obscure and why I have to misspell her name on eBay because they're doing it quietly thanks thank you so much for your presentation it was really interesting book were there any occasions particularly where Missy had to or was in a position to challenge the male establishment per se where she did and she did overcome something of that by being able to push women's issues forward was there any particular thing that strikes here comes out in episodes where she really had a big challenge and she had to find a way to overcome something of that nature Missy challenged the male establishment all the time by looking like she was not challenging the male establishment and so I'll give you a great example when she first became a political reporter she herself was a coup because it was deemed that women could not cover politics this was 20 years before she could vote and so what she would do when I said that she was coming up with this idea of political portraiture she became a political journalist by writing in a way that didn't seem like hard political coverage and then once she got in there she started to do the hard political coverage women have gotten into the public sphere and been able to play these public roles the first entree women got into the public sphere often times was through the guys of domesticity when women start to get active in social reform they do it as good mothers who want to be able to perform social service as good mothers to protect their children and Missy is very much a voice but then once she gets in that's when she actually starts to almost reinvent that space so you know when she becomes this political journalist all of a sudden men start writing in similar veins so she gets in there as this sort of through this feminine way of being goes in and then actually takes that very masculine space and actually shapes it and so it's a tactic I don't know if you were to ask Missy if she knows she's doing that but she's doing that and not just as a journalist but then when she becomes an editor she's an editor of domestic magazine she takes all of that insight she learned as a domestic editor and brings it to the New York Herald Tribune which is a hyper masculine space at the time she had other women on her staff who helped her too but it's amazing how she sort of gets and then when she gets there she almost sort of re-genders that space so she does a lot of that and almost the way that the book is organized is to show you how she does that in this context and then in the next chapter she's doing it in this context and she's doing it in politics and now she's doing it in media and now she's doing it so you know it's sort of a bounds with examples Thank you so much. Yeah, thank you Any other questions? Okay, I think we're good Thank you so much for having me Thank you. Just a reminder there is a book signing one level up in the archives bookstore the books are available at the cash registers we'll see you up there in just a few moments


So this is a jQuery plug-in unit testing. I call it get around the event loop. You'll tell me if that's a normal good name later. So I'm John K. Paul. I'm this guy who lives in New York, as Adam very graciously said earlier. I'm actually not born, raised there or anything. I just think that's the thing you're supposed to say, because you're from New York. I unit test my JavaScript. I don't know that many people who do it, at least around where I work. But I'm trying to get more people to come into it. So how many of you have unit tested in any language?  OK, how many of you have unit tested in JavaScript? Oh, OK, good. That's I'm completely guessing there's a big light here. 20%, 30%. I also happen to be a guy who uses Reveal.js, the slideshow plug-in. I hope you're not too tired of this particular thing. I also have a beard that me and Andy, the speaker from yesterday, had a good conversation about. We'll talk about it later if you want. OK, so this is my I want to show you my first plug-in. This is the first jQuery plug-in that I wrote that I would actually say that I was proud of. This is something that I put up on GitHub and very gratefully no one forked and never used. But let me show you. So this was just something where you could, I wanted an image cropper that was not like jCrop. We needed something where you could drag this around. And wherever you dragged it to, you got the coordinates. Those coordinates right now I'm just printing. But you send them to the back end. Image magic does its magic. And you get the outcome. So this plug-in, I'm showing you the code here. Don't worry about reading it. You don't actually need to know. This is Sans the boilerplate that would go around it. I thought when I first made this plug-in that I wrote something really nice. It was well-indented. It was pretty. I separated it out into functions and this crazy function thing. And because of this nice slideshow thing, it's even syntax highlighted, and it's beautiful. And I spent a lot of time concerned myself with, because I'm releasing this. I'm putting this on GitHub. That was very special a few years ago. So the reason that this was so, or the problem with this is while this code was very pretty and worked in most cases, this has tons of edge cases. This particular plug-in, I don't know if I can create any of the errors now. But actually, yeah, it was right here. I'm not actually clicking anymore. It just stuck to my mouse. If you move your mouse at a weird angle, all the math that I do in my pretty functions breaks. And I really didn't know that. And it took me a very long time to debug this. I had to put a breakpoint somewhere, or console.log, refresh the page a thousand times, try to figure out what was wrong. And it was a very, very frustrating process. I had to write code, then refresh the browser, then, in my particular case, sadly, had to find the place where the widget was on the site, then click on it to get into the right state and hope that I hit the condition where an error happened, and then debug that error. This is a very frustrating process. I'm sure we've all done it. We've all gotten used to it. But there is a better way, and that's what I'm gonna talk to you about now. At least for 80% of you, maybe some of this is new. If normally it's a much smaller group site, I can say, raise your hand and ask a question. I would say yell at me, but I don't think that's gonna work either. Definitely keep your questions, we'll talk about them after. So, this is also my last meme. So, apologize for the rest of it, it's gonna be really technical, no more pictures. So unit testing is the answer to this particular problem. Once you start unit testing your plugin code, or your code in general, you don't always need to manually test in the browser. You don't necessarily need to always be console debugging because what I'll eventually show you gets rid of a lot of that necessity. You can very quickly change the code and then see if it works, because unit testing, the whole idea of unit testing is to create code that tests your code for you. Rather than you console.logging something and then checking with your eye to see that it is correct, a unit test checks that completely in code so you can run it very quickly. It's also nice because you can test your plugin completely in isolation, so you don't have to actually put this into an app or even necessarily an HTML page that has any complexity. What I'm gonna show you is a way to write unit test plugins very, very separate from necessarily all of the HTML that you would traditionally have when you're deploying your plugin. Okay, so I think coming up soon it's gonna get crazy, so bear with me. So I don't know how many of you have tried to, how many of you who have not, do not unit test regularly, have tried to read blog posts and learn about unit testing and try to see a lot of examples out there. Okay, so this is what a lot of the examples are like. It's very straightforward stuff. So this is an example of a unit test that I wanna make sure that this particular function sums and then squares some numbers. And what I can do right now is I'm gonna run this test and it says on the side very nicely that all of these things failed because all of these things are not true. If you see my function actually doesn't return anything. There's no return. So what I can do here very easily is live coding is always dangerous, so let's see what happens. Okay, so here is the simplest unit test, the simplest piece of code. This is the idea behind unit testing. I just wrote some code to prove to myself that my function does what I expected to do. And then I wrote the function itself and said then the test passed and it said yeah, your expectations are correct. What you expect this function to do actually happens. What's nice about this is there's two big nice things about this, I'm pitching you on unit testing now, I'll get back to that everything else later. One good nice thing is someone else comes to this later and accidentally or without knowledge knowing, because I have a very obvious function name here, assuming this function name is a little more cryptic, someone comes in here and changes this to three. Eventually when you run your test, things will break and they will know that something that they just did caused a problem. Also another really good thing is I wrote this really verbosely and no one really should write code like indentation aside, I can't actually hit tab in these things. I didn't write the code to fix that. Someone can figure that out later. So what you can easily do is change this to, and now my code still passes. I know everything is still correct and I was able to refactor my code to make it look nicer. It's a lot easier for me to do that when I have the confidence that I'm not gonna make a mistake because, or rather, I can make a mistake, but that's okay because my mistake will be caught. Okay, so this particular part of unit testing is very, for very straightforward and very easy because it's just function does this particular thing and I know exactly what it's going to do. The next thing of unit testing that I'm gonna show you is also fairly easy when you have a function that doesn't actually need to do much, it doesn't need to call other functions so you don't have to fake out a lot of things. This particular function, all it does is right here, I'm gonna write, return. And here I have my passing tests. All this particular function is doing is checking the data that is on the something that is passed into that function. This is also really easy to test. Not particularly something you would normally do in a jQuery plugin, but that's where the complex part happens. So another thing that I see sometimes and I'm just giving you this that I want you to avoid it, so a lot of people test their libraries and this is, it's just a code to maintain that we don't need to. jQuery itself has something like 6,000 unit tests, I don't remember the exact number, but we don't have to worry about this. This will work. What I'm doing here is writing some code that creates a div and then adds a class to it and then makes sure that jQuery is correct and really adds that class and then adds it to the DOM and then makes sure that it really gets added to the DOM. Realistically, we don't have to worry about this. At least some big part of what you would think about testing can go away because you don't need to worry about all of what jQuery does. It's already taken care of for you. So what you care about, what we need to worry about in plugin unit testing is what do we need to do? We need to make sure that when events happen, we actually control what code does when those events happen. So for example here, it's funny, the previous speaker had an accordion example and I also have an accordion example, but we did not coordinate on this. So here I have a piece of code that in jQuery selects all the accordions and then every time you click on it, shows ULs underneath it. And this is something that's really hard to test by itself because how do you know? You actually have to have an accordion div and ULs and you don't know how to verify this. For example, if I had equals here somewhere, equal. I wouldn't actually know what to put there. It's not obvious how to make this code testable. The same is true for the next one. I add this very large function to the list of handlers that should happen when the window scrolls. It's not necessarily a good idea, this is just the example here. When the window scrolls, all of this happens, but how do I verify any of this? Do I actually need to have a window? Do I actually need to use the DOM events? I'll talk about it a little later to actually scroll the window. That's kind of really complicated. What is the best way to avoid this? Where did they get around this? The short answer of how would you test this is don't write code like this. Ideally, you wouldn't be writing code that completely couples everything where you do too much in one place. Select your elements and at the same place you add all of these handlers so there's no place for you to stick in your testing code and say this is what I want to make sure that this happens at this place. So plugins need organization, in the previous talk also, they set this up completely on purpose, which is a good thing. Plugins need organization so that we can maintain them definitely and in this case, so that we can test them more effectively. So there are patterns, there are best practices as mentioned earlier. You can Google for a jQuery basic plugin pattern, Adios money has a large GitHub repository. That's the one that I'll be using here. Hopefully I'll show you through this code a lot of different ways that you can use these patterns to help you write code that you can then easily test. Okay, so now trust me, I'm gonna show you some code. So this is basically a plugin pattern directly taken from that GitHub repository and modified to do a few things. Can everyone really hard to see? Let me just do this. I think that should be obvious, okay. So this code, what I want to do is it basically sets up a very simple plugin, this plugin when you create the plugin on a particular element, it looks up all of the ULs underneath it and then when you click on them, it shows them this most simple non-functional really accordion. And what I want to do is write a test, something like this. So what this, I want to say when I create this element, I want to create an element, a fake element that doesn't actually need to be in a page. I want to use the plugin on that element. Then I want to take that plugin instance. So what I have here, this particular plugin boilerplate, what it does is when you create an instance of a plugin, it actually just sticks it on the data object so that you can look it up later. So that's the second to last line here. You don't necessarily have to worry about that. So what happened, what I want to show here is once I activate the accordion plugin on my element, and then I want to override a function that will set this flag clicked to true for when it was originally false. So what this code is doing is verifying specifically that when the click happens, this particular function handle accordion click is called. Now how it does that is using jQuery's trigger function. So every jQuery object has a way to trigger events on it programmatically. So rather than a mouse actually having to click on an element that is in the page, you can use the trigger method to make jQuery behave as if something actually clicked. So what I'm doing here is setting everything up and then actually on the second to last line, clicking it, letting the browser click it without actually having to fire the native browser event, and then making sure that this function was called. So this is fairly straightforward. I have to have this global to that function of our variable called clicked. So there's a library called Sinon.js that makes things like this a lot easier. So with Sinon, they actually have something called a spy. Spy is a function that you can use, or it's an object, you create an instance of a spy and all it does is know that it's been called. So rather than having to do that fancy, having the variable that gets set underneath, we can use one of the Sinon spies that has a called property that will be set to true if that function actually gets called. So these are two fairly, this particular one is these are two fairly straightforward tests. I create a plugin, I create an object that plugin is instantiated on, then I try to click or something, I'd actually use an event and then make sure that what I expect to happen when the event happens, it actually does happen, in this case, making sure the handle according click is called. So the pattern here that we need to learn is normally, so traditionally this could be written, this particular init function, when I actually add the click handler, this could be written very differently, this could be written in a way where I, for example, do this. So this could be written in a way where I do not actually put handle according click into a separate function. I could do that directly here, I could type here. So if I did this, I would have nowhere for my testing code to inject its fake function to make sure that that was called. So a big part about how to unit test plugins is to make sure that you separate everything out into ways that you can override. It's called traditionally in the jargon of unit testing, this is called a seam. We need to make as many seams as possible where we can put our fake implementations, in this particular case, I faked out handle according click because that's where I know, if I can verify that that's been called, at least I know that half of things is covered. So back to what this was normally. So now the test that I just showed you, it verifies for sure that when this, when the element that this plugin is created on is instantiated on, when that element is clicked, handle according click is called. So I've covered half the goal because I wanna make sure that the click method is called and then I wanna make sure that if that click method is called that in this particular case, all of those ULs are hidden. So let me show you the next test. Okay, so here I'm using these document.app, I mean the create elements here rather than the jQuery dom builder, just because this syntax highlighter breaks a little bit with HTML. So what I'm doing here is creating a UL and the correct elements, putting them together correctly, and then I'm actually calling that the function handle according click directly and I'm making sure that the CSS display is blocked. I'm making sure that it's been shown. This is a way you can, once you've separated your plugin code out, where you can easily test things separately, then this is fairly straightforward, other than most of this code is building the DOM. And what, so using jQuery's dom builder, which is the jQuery function itself can actually take HTML as a string. In 1.8 this is changing to be a little different, but you can read that blog post. Also, you could also use fixtures, which are blocks of HTML that are in your HTML page at the time that this test runs. This particular, I mean inside this slideshow I'm actually using QUnit. There are many, there are other frameworks as well and QUnit has a traditional QUnit fixtures div where you can put whatever HTML you want to use in your particular tests. So I'm gonna move on to the next plugin that I wanna show you how to build. So this is a fairly common requirement nowadays. The businesses want, or designers want this, oh, this is, of course this demo is not working at the worst possible moment. Well, so normally that would stick to the top. I'm assuming that I'm not on the internet or something and the jQuery on CDN is broken. But I wanna build something where when I scroll the scroll bar down and this particular green div hits the top that I wanted to stick there and then not keep scrolling with the page. So somewhere I have some code like this. Let me zoom in. And what this code is doing is when the window scrolls it checks to see if the element is outside of the viewport and then if it is outside of the viewport it calls some function. This is that pattern that I was showing you earlier, at least that practice where rather than putting all of your code in line, call out to functions that you can eventually override and then in your unit tests verify that are called. I'm not showing in this particular example but you can actually verify that things were called with particular arguments. You can verify that when things are called that they return particular arguments there's the sign on JS library has a large amount of different types of spies and there are other different things that you can use. So what this code is doing, sorry, I told you what this code is doing. I have this element outside viewport function that's a nice separated function thing so it looks really nice and maintainable. So I want to have a test like this. So this is where I create an element, I add my plugin to it and then I get the particular plugin from my data. It just happens to be the pattern that I'm using and then I make sure that when the window actually scrolls by creating this, this is a custom jQuery event. You can create an event using the jQuery event constructor and you can have that event be whatever you want. You could create a click here. The reason that I'm triggering with an actual object rather than a string, I could click here, I could just have the word scroll. This would trigger scroll on window but I'm actually creating an event because I want to make sure that even though there's no actual window necessarily there's not necessarily a browser, there's not necessarily a page or a scroll bar, I need to make sure that when jQuery says what is the scroll top of this window, I need to make sure that it says in this particular example 101 because I want to pretend that the window has scrolled down by 101 pixels. So that's why I create a jQuery event that I add to that, I specify the target of that event as an element that happens to have scroll top as 101 and then I trigger that event on the window. This is, it's a little bit a roundabout way but this is the way that you can write a unit test that correctly gives the right value. The biggest part of unit test is how to figure out ways to give the right values to your actual production code. So in this case, so when I run this, yeah, so I can run this and it will actually show you what happens. Let me see, so now I'm gonna scroll this to, so anyway, I know something particularly is not working but this I think happens every once in a while. So I wanna show you, so this test, this is how you would write this test in order to verify that when something scrolls something happens but I wanna show you how to find out how to specify where your element is on the page. So the element that I showed you here this green element right here, this green element might or might not or because it's a fake element it might be completely at the top of the page it might not necessarily be on a page at all. So how would you find out how to specify in your code where that element should be? That's this element that's created right here. The element that will eventually be stuck to the top of the page. So in order to find that out, basically my code in here is calling offset. This.element.offset. So I need to somehow make jQuery for that offset return back the values that I want. I want, I need to make sure that that if I want to scroll to 100 pixels and my element is at 110 pixels that nothing happens because it hasn't been scrolled past. If I want to make sure that it's been, if it's at 100 pixels and I scroll to 101 then that's okay. I don't know if that logic made sense but I'll show you what I'm talking about. So basically I need to override what offset returns but this is, this is in jQuery. How do you, how do you do that? And it's taken a while for me to get used to this or comfortable with this but you can actually look into the jQuery code and often it's crazy and you don't understand it but sometimes you work at it and you read it a little bit and it's okay and I'm gonna show you in this particular case it's a little bit daunting but we can figure out where to write our code, how to write our code to let, to inject into jQuery what it needs to be able to control what it returns in this particular case, controlling what offset returns. So, so this is the code for offset. It is long and a little complicated but let me zoom in for you. Okay, so there are not that many returns here. So if there are not that many returns we can just go through them and figure out where it is that we can write, how we can write our code so that we can control what offset returns. Okay, so the first one is if options. We're not passing anything into this so it's obviously not this return. The next one is return null. We don't want it to return null because maybe it's not gonna return null because it doesn't normally return null. Next one is return this body offset. Why would it return the body offset? If the element that it's on is the body which is not the case. So it's definitely not that one. Okay, skip all of this, don't understand it, don't need to worry about it yet. Skip all of this, return, okay. Return box. So if box is there, return box.top and box.left. Okay, so that means that I kind of know what they're returning. I don't know why they're doing this but I'm reading the code and I'm seeing that this is happening. So let me go up a little bit. Where is box defined? So box is the elements get bounding client rect. Okay, I don't know what that means. I have no idea what that means. I could look up at MDN but I don't know what that means. But I know that if I have an element and that element has a function called get bounding client rect on it, I can override that function and do whatever I want. So let's go back. So if I want to specify, yes, sorry, one second. So what I can do here is override the element specifically, override the function that I know jQuery is calling because I read it. I don't know why it's calling that but I know that now that I can stick in here some data and say that there we go. Okay, so my test just failed because I specified that my element is at 100 pixels yet but I have only scrolled to 99, okay? But let me change this to 101. Pass, my test just passed because I told, I've override the function that jQuery calls internally to say that the new element that I just created, sorry, we'll zoom in, the new element that I just created is at 100 pixels from the top and 100 pixels from the left and the window itself has scrolled 101 pixels. So that means that, wait, this code is wrong. It should have actually, the element scrolled off should not have been called. So my test passes. Other way around. So this is how you can read jQuery source not necessarily understand what it's doing or why it's doing what it's doing but you actually can find out. If you Google for get bounding client rect there is information out there. I'm sure that there's other documentation on MDN that'll make this make sense but you don't necessarily need to know that when you're concerned with unit testing your plugins. All you need to do is understand that there are places in jQuery and in your code that you can override certain properties to return what you want so that you can successfully test your plugins. So that you can put everything in the right state without actually needing a browser or actually needing, without actually needing HTML and an entire page backing everything up. Okay, so I'm gonna do a quick explanation of AJAX tests. I've, that's, well, I'll figure out about time. I've started a little early so let's see what happens. So I have a very quick example of a plugin here that doesn't do much except it makes an AJAX request to this URL data and then when it returns it sets the text of the element that the plugin was graded on with the message property of the JSON data that was sent back. So normally an AJAX test is kind of complicated to write by itself even if you have a backend because these are asynchronous. So rather than being able to test like completely insurial you have to have eventually in your test something that would pause and say let's wait a little bit of time, set time out for some time in the future when that AJAX call returns you have to figure, you have to figure everything out then. But Sinon has this great feature called use fake, use fake XML HTTP request. And what this does, even though it is complicated to say, is it gives you back an XHR object and it overwrites the native XHR to use something that is completely synchronous and you can control programmatically. So, whoa, that was very loud. So basically using this Sinon fake XML HTTP request you can create these XML HTTP request objects that in this particular code I'm just storing in some variable. And then if you see on this line I'm creating that AJAX plugin. That AJAX plugin should go out, it should make this AJAX call and then return and populate the data correctly in my element. But what I can do here, this is the really nice part in my unit test. I can respond to that request in my JavaScript. I don't have a backend here. I don't necessarily even need to have a network connection or anything like that. I'm saying this fake XHR that's been created that's requested for data, respond with a 200, respond with these headers in this particular data. In this case I'm sending back the message, and then I can make sure that afterward the text in this element contains the text that I specified from my, the fake response from the server. So we could actually create actual integration tests which is the integration tests are tests that test multiple components. So unit tests test a single class or module or plugin in this case or anything. We could create real events. There is a way to do that. It feels a little more honest because here we're using jQuery's trigger and we're making some, making the assumption that triggering is the same thing. It's not exactly the same thing as using a native event that can actually click on something. You could use, there's a method in, on the document called document.createEvent. When you can create a mouse event in this case then you can initialize that mouse event and then you can trigger that mouse event on an element. You can, eventually I'll give you the links to this. But the amount of frustration that comes from this is almost exactly the same as the amount of frustration that comes from not even unit testing your code at all and having to debug forever. Because the, one of the, a knit mouse event, I think takes 14 different parameters and half of them are Boolean and I have no memory of what they all do and I have very often attempted and gotten all of them very, very wrong. So realistically there, it's not something that I would use and want to be able to, or not something that I think I would be able to successfully use regularly. Also I actually made a JS perf to compare using real browser events with these jQuery triggered events and realistically the difference is not that much at all. So basically in summary we talked about how to utilize event, jQuery's event objects and triggering events programmatically through your code and using that able to make sure and verify that what you expect to happen actually did happen. Then so write your plugins with seams, with methods that you can override, that you can say, oh my spy will go here and I'll make sure that that's called and I'll make sure that that's called with a particular piece of data or something like that. You, there was a lot of utility libraries. I have some resources. Sign on JS is the one that I use most regularly. There's also jQuery mock jacks which is a mocking library that has the same interface as jQuery's Ajax itself. Also read the source, some of it's crazy and you don't have to understand but a lot of good places where you can put your mock data comes from there. So these are the resources. Okay, thank you so much for listening. Do you have any questions? These are all of my information. I'm on IRC all day and there's a link to the presentation. I just wondered, have you found it more helpful to use trigger versus trigger handler in your testing meaning? Have you ever run into a case where an actual note event was actually fired during any of your mocking? No, I have not used that at all. Never used trigger handler? No, I've used trigger handler. I've never seen, for testing I don't believe so. Okay. Okay. All right, I got a question because we were running out a lot of tests about this integration as we're using Qnet. So one of the pain point is that how do you, let's say, how do you deal with the asynchronous test? Like situations? Good question. Things like, okay, what do you present over there? I see that there's pretty much almost instant because there's nothing really involved about like because let's say you had a Ajax but it's a mock one so it returns immediately. So what's your strategy in terms of dealing with things? I'll explain. So this is kind of sound kind of cheating because Sinon actually has a library. I can show you, I think. Okay, so Sinon has another component like fake XML HTTP request where it actually overrides set timeout and set interval. So in the exact same fashion as you can fake out requests that come back from your server, you can actually tick the clock. So you can say, you can write fake set timeout or set timeout is overriding. So you can say global clock dot tick 100 seconds, 100 milliseconds. And when that happens, it actually behaves correctly. Everything that was set timeout, set for 100 milliseconds will fire at that time. So you can set it up to the clock to tick at 99, make sure that everything is as expected, then tick pass to 101 and make sure that everything is expected. That that library mocks everything out for you. I think that, sorry, I didn't hear the whole question but I think that that addressed. Okay, I think we use a similar approach like that. Like say we deliberately wait a few moments just to say, hey, supposedly the Ajax comes back. Supposedly the browser has done its own rendering that we run through like plugins and then we need to make some time just to kind of gauge it. Sorry, can you speak up? Okay, have you thought about using some sort of callback patterns in terms of dealing with like, you wanna make sure some DOM element or some images fully loaded after you did some requests. So how do you measure that? Okay, something is already there and then you can move on to the next step. So if an image is, so this is a unit test. So in a unit test, I would try to have as few dependencies as possible outside of that. So I would try to trigger that event programmatically and say that image is loaded now, what happens? And then maybe in another case in another test, say, oh, that image failed loading, what should happen, does that happen? Right, exactly. I think the particular thing we're asking is about integration tests. So I think this is rarely happening in unit tests. Right, so with integration tests, in that particular case, I have not done significant work with attempting to write integration tests for issues like that, so to be honest, I don't know. But I guess I would try not to have to worry about tests like that, where I actually depend on an image being loaded from the back end. Potentially if this is of extreme business importance, you could, there is other tools that would be more appropriate, like Selenium, Selenium a web driver, there are functional testing tools that will let you actually use an actual browser and have it, for example, set up something where an image takes two seconds to load, actually physically click with a mouse that's moving and verify that your, because your back end took two seconds, X happens, if it takes five seconds, Y should happen. Something like that would be more appropriate for a different testing methodology. But I would try to avoid that, to be honest with you, because it's a lot of overhead that you don't necessarily need to spend time on. It depends. How do you know how much testing is appropriate?  How much do you need to do? Well, I'm sure that those tests came over the course of a billion bug reports. So I don't know if that's necessarily that's the right comparison. It depends on what you're talking about. So I think that business logic, so this is kind of separate from plugins. So in terms of plugins, you should be unit testing as much as makes things, definitely makes things easy for you and also makes sure that what your user expects to happen happens. Not necessarily all of your internal logic to do that, but in my example, I wanna make sure that when I click the accordion, the accordion shows, I think that's a very common thing. In general, what to unit test is a much larger, or what to test is a much larger problem. The example of integration tests, in my opinion, make sure that you can pay and then really make sure you can pay and then make sure you can pay and then don't worry about anything else. In terms of unit testing, it is, there are coverage tools, there are unit tests, JavaScript has JS coverage and you can make sure that each line of code is covered. That's not necessarily that valuable, it depends on how they are covered. You could write very inane tests and just claim that you have very high percentage of coverage. I guess in general, that's a complicated question. Test your business logic, test what is important to your company and then test to make sure that you're implementing something the same. I would love to talk to you more about that afterwards. I think it's a long question and my time is officially over. There's a tool called SYN, S-Y-N that I think wraps around document.create-event and it makes it much easier to create synthetic events for testing and it might give you truer results than trigger. Sorry, what was the name of it? SYN, S-Y-N. Okay, so SYN, I did not know about that one. There's also jQuery, for jQuery UI has jQuery, the simulate plugin which maps, I think, directly to trigger. So you can simulate a click event and you can simulate a key down event. In the same way, it calls into document.create-event under the hood. You don't necessarily have to worry about all of the parameters that I mentioned earlier. There are other tools in order to do that but the problem there, it's a little confusing to know how to use it correctly because while you can create those actual events, you can no longer write code that is synchronous because when an actual event happens, the handler isn't triggered in the same execution thread of JavaScript. That click is added to the event loop and then eventually the next tick of the event loop that is picked up and that code is written. So your test will be written very differently if you write that kind of test. Anything else? Oh, there's one over there, oh, Cory. Oh, okay. This is gonna be interesting. It's not like you're my planter. So I was just curious if you had any good solutions for dealing with testing in particular focus. It's been the biggest pain event to try to get working and simulate for UI. We've had a lot of problems in dealing with all the browser asynchronicity around focus. There's just a lot of problems with it. I didn't know if you had a good solution. So no, I mean in terms of actual browser events, I have not tried to be honest. I think as I try my best, or I always honestly write tests, at least when I'm using jQuery, where jQuery triggers those events themselves rather than having the browser trigger them. Other than using the normal asynch testing tools, I don't know of any other way to fake that out. Maybe I will look into it though. I will get back to you. Sure, we'll talk after. Okay, thank you so much. Definitely ask me questions if you have them later. I would love to talk to you.


Google says that 7% of your body weight is made out of blood, and also that if you have a million 200,000 mosquitoes taking a bite out of your body at the same time they will drain your body out of all your blood. I pray this will never happen to you. Blood is a very vital part of our body. Without it our body cannot function. Without blood your physical body cannot properly function. Blood has a lot of functions in the body. For example one of the first functions the body it has in the body is it it collects carbon dioxide, ammonia, and other waste from our body. It transports nutrients to our body. It also carries hormones to our body.  Blood also carries oxygen to your body. Blood also is in your body to maintain balance in fluids. Blood in your body has a function also to fight microorganisms that come and attack your body.  It will still have the bones, it will still have the structure, it will still have the features, but it will not have life. That's why the Bible says that life is in the blood.  That means if you remove the blood you can still have the body, but no life. Body cannot function without blood. If our physical body cannot function without blood the body of Jesus Christ which is the church cannot function without the blood of Jesus Christ. We can still have a structure, we can still have principles, we can still have organization, we can still have management and we can still have good morals, we can still have great families, but one thing that will be missing when the blood is missing and that is life. Because life does not come from organization. Life comes from the blood and when you drain the body out of the blood you will still have a body, but it will be a corpse, not a body. And the vital part of a Christian life and the vital part of a church in the 21st century is the same vital part that was of the church in the first century. It's the blood of Jesus Christ. That's why Paul says that I am not ashamed of the gospel of Jesus Christ, for it is the power of God to those who believe. Can somebody say amen?